8000 Obsolete repo.Commit() overloads that do not require Signature parame… · github/libgit2sharp@b69e3e2 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Feb 3, 2023. It is now read-only.

Commit b69e3e2

Browse files
committed
Obsolete repo.Commit() overloads that do not require Signature parameters
1 parent 818654b commit b69e3e2

File tree

4 files changed

+28
-22
lines changed

4 files changed

+28
-22
lines changed

LibGit2Sharp.Tests/CommitFixture.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,9 @@ public void CanCommitWithSignatureFromConfig()
560560

561561
Assert.Null(repo.Head[relativeFilepath]);
562562

563-
Commit commit = repo.Commit("Initial egotistic commit");
563+
Signature signature = repo.Config.BuildSignature(DateTimeOffset.Now);
564+
565+
Commit commit = repo.Commit("Initial egotistic commit", signature, signature);
564566

565567
AssertBlobContent(repo.Head[relativeFilepath], "nulltoken\n");
566568
AssertBlobContent(commit[relativeFilepath], "nulltoken\n");

LibGit2Sharp.Tests/FilterFixture.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public void CleanFilterWritesOutputToObjectTree()
159159
using (var repo = CreateTestRepository(repoPath))
160160
{
161161
FileInfo expectedFile = StageNewFile(repo, decodedInput);
162-
var commit = repo.Commit("Clean that file");
162+
var commit = repo.Commit("Clean that file", Constants.Signature, Constants.Signature);
163163
var blob = (Blob)commit.Tree[expectedFile.Name].Target;
164164

165165
var textDetected = blob.GetContentText();
@@ -240,7 +240,7 @@ public void CanFilterLargeFiles()
240240
File.WriteAllText(attributesPath, "*.blob filter=test");
241241
repo.Stage(attributesFile.Name);
242242
repo.Stage(contentFile.Name);
243-
repo.Commit("test");
243+
repo.Commit("test", Constants.Signature, Constants.Signature);
244244
contentFile.Delete();
245245
repo.Checkout("HEAD", new CheckoutOptions() { CheckoutModifiers = CheckoutModifiers.Force });
246246
}
@@ -346,7 +346,7 @@ private FileInfo CheckoutFileForSmudge(string repoPath, string branchName, strin
346346
{
347347
StageNewFile(repo, content);
348348

349-
repo.Commit("Initial commit");
349+
repo.Commit("Initial commit", Constants.Signature, Constants.Signature);
350350

351351
expectedPath = CommitFileOnBranch(repo, branchName, content);
352352

@@ -363,7 +363,7 @@ private static FileInfo CommitFileOnBranch(Repository repo, string branchName, S
363363
repo.Checkout(branch.FriendlyName);
364364

365365
FileInfo expectedPath = StageNewFile(repo, content);
366-
repo.Commit("Commit");
366+
repo.Commit("Commit", Constants.Signature, Constants.Signature);
367367
return expectedPath;
368368
}
369369

LibGit2Sharp.Tests/FilterSubstitutionCipherFixture.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,15 @@ private static void DeleteFile(Repository repo, string fileName)
203203
{
204204
File.Delete(Path.Combine(repo.Info.WorkingDirectory, fileName));
205205
repo.Stage(fileName);
206-
repo.Commit("remove file");
206+
repo.Commit("remove file", Constants.Signature, Constants.Signature);
207207
}
208208

209209
private static Blob CommitOnBranchAndReturnDatabaseBlob(Repository repo, string fileName, string input)
210210
{
211211
Touch(repo.Info.WorkingDirectory, fileName, input);
212212
repo.Stage(fileName);
213213

214-
var commit = repo.Commit("new file");
214+
var commit = repo.Commit("new file", Constants.Signature, Constants.Signature);
215215

216216
var blob = (Blob)commit.Tree[fileName].Target;
217217
return blob;

LibGit2Sharp/RepositoryExtensions.cs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ private static Commit LookUpCommit(IRepository repository, string committish)
219219
/// <param name="repository">The <see cref="Repository"/> being worked with.</param>
220220
/// <param name="message">The description of why a change was made to the repository.</param>
221221
/// <returns>The generated <see cref="LibGit2Sharp.Commit"/>.</returns>
222+
[Obsolete("This method will be removed in the next release. Please use Commit(string, Signature, Signature) instead.")]
222223
public static Commit Commit(this IRepository repository, string message)
223224
{
224225
return repository.Commit(message, (CommitOptions)null);
@@ -234,6 +235,7 @@ public static Commit Commit(this IRepository repository, string message)
234235
/// <param name="message">The description of why a change was made to the repository.</param>
235236
/// <param name="options">The <see cref="CommitOptions"/> that specify the commit behavior.</param>
236237
/// <returns>The generated <see cref="LibGit2Sharp.Commit"/>.</returns>
238+
[Obsolete("This method will be removed in the next release. Please use Commit(string, Signature, Signature, CommitOptions) instead.")]
237239
public static Commit Commit(this IRepository repository, string message, CommitOptions options)
238240
{
239241
Signature author = repository.Config.BuildSignatureOrThrow(DateTimeOffset.Now);
@@ -251,6 +253,7 @@ public static Commit Commit(this IRepository repository, string message, CommitO
251253
/// <param name="author">The <see cref="Signature"/> of who made the change.</param>
252254
/// <param name="message">The description of why a change was made to the repository.</param>
253255
/// <returns>The generated <see cref="LibGit2Sharp.Commit"/>.</returns>
256+
[Obsolete("This method will be removed in the next release. Please use Commit(string, Signature, Signature) instead.")]
254257
public static Commit Commit(this IRepository repository, string message, Signature author)
255258
{
256259
return repository.Commit(message, author, (CommitOptions)null);
@@ -267,13 +270,29 @@ public static Commit Commit(this IRepository repository, string message, Signatu
267270
/// <param name="message">The description of why a change was made to the repository.</param>
268271
/// <param name="options">The <see cref="CommitOptions"/> that specify the commit behavior.</param>
269272
/// <returns>The generated <see cref="LibGit2Sharp.Commit"/>.</returns>
273+
[Obsolete("This method will be removed in the next release. Please use Commit(string, Signature, Signature, CommitOptions) instead.")]
270274
public static Commit Commit(this IRepository repository, string message, Signature author, CommitOptions options)
271275
{
272276
Signature committer = repository.Config.BuildSignatureOrThrow(DateTimeOffset.Now);
273277

274278
return repository.Commit(message, author, committer, options);
275279
}
276280

281+
/// <summary>
282+
/// Stores the content of the <see cref="Repository.Index"/> as a new <see cref="LibGit2Sharp.Commit"/> into the repository.
283+
/// The tip of the <see cref="Repository.Head"/> will be used as the parent of this new Commit.
284+
/// Once the commit is created, the <see cref="Repository.Head"/> will move forward to point at it.
285+
/// </summary>
286+
/// <param name="repository">The <see cref="IRepository"/> being worked with.</param>
287+
/// <param name="message">The description of why a change was made to the repository.</param>
288+
/// <param name="author">The <see cref="Signature"/> of who made the change.</param>
289+
/// <param name="committer">The <see cref="Signature"/> of who added the change to the repository.</param>
290+
/// <returns>The generated <see cref="LibGit2Sharp.Commit"/>.</returns>
291+
public static Commit Commit(this IRepository repository, string message, Signature author, Signature committer)
292+
{
293+
return repository.Commit(message, author, committer, default(CommitOptions));
294+
}
295+
277296
/// <summary>
278297
/// Fetch from the specified remote.
279298
/// </summary>
@@ -601,21 +620,6 @@ public static void Reset(this IRepository repository, Commit commit)
601620
repository.Index.Replace(commit, null, null);
602621
}
603622

604-
/// <summary>
605-
/// Stores the content of the <see cref="Repository.Index"/> as a new <see cref="LibGit2Sharp.Commit"/> into the repository.
606-
/// The tip of the <see cref="Repository.Head"/> will be used as the parent of this new Commit.
607-
/// Once the commit is created, the <see cref="Repository.Head"/> will move forward to point at it.
608-
/// </summary>
609-
/// <param name="repository">The <see cref="IRepository"/> being worked with.</param>
610-
/// <param name="message">The description of why a change was made to the repository.</param>
611-
/// <param name="author">The <see cref="Signature"/> of who made the change.</param>
612-
/// <param name="committer">The <see cref="Signature"/> of who added the change to the repository.</param>
613-
/// <returns>The generated <see cref="LibGit2Sharp.Commit"/>.</returns>
614-
public static Commit Commit(this IRepository repository, string message, Signature author, Signature committer)
615-
{
616-
return repository.Commit(message, author, committer, null);
617-
}
618-
619623
/// <summary>
620624
/// Find where each line of a file originated.
621625
/// </summary>

0 commit comments

Comments
 (0)
0