diff options
Diffstat (limited to 'LibGit2Sharp/RepositoryExtensions.cs')
-rw-r--r-- | LibGit2Sharp/RepositoryExtensions.cs | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/LibGit2Sharp/RepositoryExtensions.cs b/LibGit2Sharp/RepositoryExtensions.cs index 82742350..d6e751b2 100644 --- a/LibGit2Sharp/RepositoryExtensions.cs +++ b/LibGit2Sharp/RepositoryExtensions.cs @@ -204,13 +204,31 @@ namespace LibGit2Sharp /// </summary> /// <param name="repository">The <see cref="Repository"/> being worked with.</param> /// <param name="message">The description of why a change was made to the repository.</param> + /// <param name="options">The <see cref="CommitOptions"/> that specify the commit behavior.</param> + /// <returns>The generated <see cref="LibGit2Sharp.Commit"/>.</returns> + public static Commit Commit(this IRepository repository, string message, CommitOptions options = null) + { + Signature author = repository.Config.BuildSignature(DateTimeOffset.Now, true); + + return repository.Commit(message, author, options); + } + + /// <summary> + /// Stores the content of the <see cref="Repository.Index"/> as a new <see cref="LibGit2Sharp.Commit"/> into the repository. + /// The tip of the <see cref="Repository.Head"/> will be used as the parent of this new Commit. + /// Once the commit is created, the <see cref="Repository.Head"/> will move forward to point at it. + /// <para>Both the Author and Committer will be guessed from the Git configuration. An exception will be raised if no configuration is reachable.</para> + /// </summary> + /// <param name="repository">The <see cref="Repository"/> being worked with.</param> + /// <param name="message">The description of why a change was made to the repository.</param> /// <param name="amendPreviousCommit">True to amend the current <see cref="LibGit2Sharp.Commit"/> pointed at by <see cref="Repository.Head"/>, false otherwise.</param> /// <returns>The generated <see cref="LibGit2Sharp.Commit"/>.</returns> - public static Commit Commit(this IRepository repository, string message, bool amendPreviousCommit = false) + [Obsolete("This method will be removed in the next release. Please use a Commit overload that accepts a CommitOptions instead.")] + public static Commit Commit(this IRepository repository, string message, bool amendPreviousCommit) { Signature author = repository.Config.BuildSignature(DateTimeOffset.Now, true); - return repository.Commit(message, author, amendPreviousCommit); + return repository.Commit(message, author, new CommitOptions { AmendPreviousCommit = amendPreviousCommit }); } /// <summary> @@ -222,13 +240,30 @@ namespace LibGit2Sharp /// <param name="repository">The <see cref="Repository"/> being worked with.</param> /// <param name="author">The <see cref="Signature"/> of who made the change.</param> /// <param name="message">The description of why a change was made to the repository.</param> - /// <param name="amendPreviousCommit">True to amend the current <see cref="LibGit2Sharp.Commit"/> pointed at by <see cref="Repository.Head"/>, false otherwise.</param> + /// <param name="options">The <see cref="CommitOptions"/> that specify the commit behavior.</param> /// <returns>The generated <see cref="LibGit2Sharp.Commit"/>.</returns> - public static Commit Commit(this IRepository repository, string message, Signature author, bool amendPreviousCommit = false) + public static Commit Commit(this IRepository repository, string message, Signature author, CommitOptions options = null) { Signature committer = repository.Config.BuildSignature(DateTimeOffset.Now, true); - return repository.Commit(message, author, committer, amendPreviousCommit); + return repository.Commit(message, author, committer, options); + } + + /// <summary> + /// Stores the content of the <see cref="Repository.Index"/> as a new <see cref="LibGit2Sharp.Commit"/> into the repository. + /// The tip of the <see cref="Repository.Head"/> will be used as the parent of this new Commit. + /// Once the commit is created, the <see cref="Repository.Head"/> will move forward to point at it. + /// <para>The Committer will be guessed from the Git configuration. An exception will be raised if no configuration is reachable.</para> + /// </summary> + /// <param name="repository">The <see cref="Repository"/> being worked with.</param> + /// <param name="author">The <see cref="Signature"/> of who made the change.</param> + /// <param name="message">The description of why a change was made to the repository.</param> + /// <param name="amendPreviousCommit">True to amend the current <see cref="LibGit2Sharp.Commit"/> pointed at by <see cref="Repository.Head"/>, false otherwise.</param> + /// <returns>The generated <see cref="LibGit2Sharp.Commit"/>.</returns> + [Obsolete("This method will be removed in the next release. Please use a Commit overload that accepts a CommitOptions instead.")] + public static Commit Commit(this IRepository repository, string message, Signature author, bool amendPreviousCommit) + { + return repository.Commit(message, author, new CommitOptions { AmendPreviousCommit = amendPreviousCommit }); } /// <summary> |