Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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 1 commit into from
Feb 7, 2014

Conversation

amibar
Copy link
Contributor

@amibar amibar commented Feb 6, 2014

This solves issue #611

var newCommit = repo.ObjectDatabase.CreateCommit(newHeader.Author,
newHeader.Committer,
newHeader.Message,
true,
Copy link
Member

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

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. See #621

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shouldn't change the data the user told us to put into the commit.

This

@amibar
Copy link
Contributor Author

amibar commented Feb 6, 2014

@nulltoken, This is the behavior of the original version, without this a lot of unit tests fail.
So I didn't want to break anything.

/// <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 (converts crlf to lf), or false to leave it as is</param>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

converts crlf to lf

Beside this, this function does a little more than that:

  • Remove empty lines from the beginning and end
  • Remove trailing spaces from every line.
  • Turn multiple consecutive empty lines between paragraphs into just one empty line.
  • Ensure the commit message ends with a newline
  • Remove every line starting with "#".

How about removing the (convert crlf to lf) part from the param description and adding a <para>...</para> describing this under the <summary/> function xml doc node?

@amibar
Copy link
Contributor Author

amibar commented Feb 6, 2014

@nulltoken, I updated the commit amibar@146ba84

/// <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>
/// <para>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this whole <para/> section should be moved under the <summary/> one so that it reads like

/// <summary>
/// Inserts a <see cref="Commit"/> into the object database, referencing an existing <see cref="Tree"/>.
/// <para>
///   Prettifying 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>

@amibar
Copy link
Contributor Author

amibar commented Feb 6, 2014

Fixed the para

@nulltoken
Copy link
Member

👍 For me. Anyone else willing to chime in?

@dahlbyk
Copy link
Member

dahlbyk commented Feb 6, 2014

No objection here

@nulltoken
Copy link
Member

@amibar Could you please rebase this on the latest vNext?

@amibar
Copy link
Contributor Author

amibar commented Feb 7, 2014

@nulltoken, done

@@ -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]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duh. I overlooked this. Sorry. Could you please add a message to the attribute in order to redirect the user to the proper overload to use?

eg.

[Obsolete("This method will be removed in the next release. Please use CreateCommit(Signature, Signature, string, bool, Tree, IEnumerable<Commit>) instead.")]

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 "#".

Note that this has nothing to do with the core.autocrlf option.
@amibar
Copy link
Contributor Author

amibar commented Feb 7, 2014

@nulltoken, updated [obsolete] message

@nulltoken nulltoken merged commit 0e94aa5 into libgit2:vNext Feb 7, 2014
@nulltoken
Copy link
Member

...and merged!

@amibar Very nice job here! Thanks a lot 👍

@nulltoken nulltoken added this to the v0.16.0 milestone Feb 19, 2014
@nulltoken nulltoken modified the milestones: v0.17.0, v0.16.0 Mar 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants