Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 922
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| 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> | ||
Member 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); | ||
| } | ||
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--interactivewould 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