-
Notifications
You must be signed in to change notification settings - Fork 909
Added an option to choose if commit message is prettified or not #619
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -191,12 +191,36 @@ public virtual Tree CreateTree(TreeDefinition treeDefinition) | |
/// <param name="tree">The <see cref="Tree"/> of the <see cref="Commit"/> to be created.</param> | ||
/// <param name="parents">The parents of the <see cref="Commit"/> to be created.</param> | ||
/// <returns>The created <see cref="Commit"/>.</returns> | ||
[Obsolete("This method will be removed in the next release. Please use CreateCommit(Signature, Signature, string, bool, Tree, IEnumerable<Commit>) instead.")] | ||
public virtual Commit CreateCommit(string message, Signature author, Signature committer, Tree tree, IEnumerable<Commit> parents) | ||
{ | ||
return CreateCommit(message, author, committer, tree, parents, null); | ||
return CreateCommit(author, committer, message, true, tree, parents, null); | ||
} | ||
|
||
internal Commit CreateCommit(string message, Signature author, Signature committer, Tree tree, IEnumerable<Commit> parents, string referenceName) | ||
/// <summary> | ||
/// Inserts a <see cref="Commit"/> into the object database, referencing an existing <see cref="Tree"/>. | ||
/// <para> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this whole
|
||
/// Prettifing the message includes: | ||
/// * Removing empty lines from the beginning and end. | ||
/// * Removing trailing spaces from every line. | ||
/// * Turning multiple consecutive empty lines between paragraphs into just one empty line. | ||
/// * Ensuring the commit message ends with a newline. | ||
/// * Removing every line starting with "#". | ||
/// </para> | ||
/// </summary> | ||
/// <param name="author">The <see cref="Signature"/> of who made the change.</param> | ||
/// <param name="committer">The <see cref="Signature"/> of who added the change to the repository.</param> | ||
/// <param name="message">The description of why a change was made to the repository.</param> | ||
/// <param name="prettifyMessage">True to prettify the message, or false to leave it as is</param> | ||
/// <param name="tree">The <see cref="Tree"/> of the <see cref="Commit"/> to be created.</param> | ||
/// <param name="parents">The parents of the <see cref="Commit"/> to be created.</param> | ||
/// <returns>The created <see cref="Commit"/>.</returns> | ||
public virtual Commit CreateCommit(Signature author, Signature committer, string message, bool prettifyMessage, Tree tree, IEnumerable<Commit> parents) | ||
{ | ||
return CreateCommit(author, committer, message, prettifyMessage, tree, parents, null); | ||
} | ||
|
||
internal Commit CreateCommit(Signature author, Signature committer, string message, bool prettifyMessage, Tree tree, IEnumerable<Commit> parents, string referenceName) | ||
{ | ||
Ensure.ArgumentNotNull(message, "message"); | ||
Ensure.ArgumentDoesNotContainZeroByte(message, "message"); | ||
|
@@ -205,10 +229,13 @@ internal Commit CreateCommit(string message, Signature author, Signature committ | |
Ensure.ArgumentNotNull(tree, "tree"); | ||
Ensure.ArgumentNotNull(parents, "parents"); | ||
|
||
string prettifiedMessage = Proxy.git_message_prettify(message); | ||
if (prettifyMessage) | ||
{ | ||
message = Proxy.git_message_prettify(message); | ||
} | ||
GitOid[] parentIds = parents.Select(p => p.Id.Oid).ToArray(); | ||
|
||
ObjectId commitId = Proxy.git_commit_create(repo.Handle, referenceName, author, committer, prettifiedMessage, tree, parentIds); | ||
ObjectId commitId = Proxy.git_commit_create(repo.Handle, referenceName, author, committer, message, tree, parentIds); | ||
|
||
return repo.Lookup<Commit>(commitId); | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure whether or not we should prettify the message when rewriting the history.
/cc @dahlbyk @ben @carlosmn
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think any rewrite should be explicitly done by the user. I'm not all that familiar with this code, but it looks like the user gets to return the whole set, in which case they should run the text through the prettify function if they want to (e.g. the equivalent of the 'reword' option in
git-rebase--interactive
would likely want to do this, as the user was asked for input), but we shouldn't change the data the user told us to put into the commit.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll create another issue to specifically deal with this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. See #621
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This