Skip to content

Enable config based ignoring of commits/messages that incorrectly inc… #470

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

Conversation

Sacrelicious
Copy link

…rement version

The latest changes to the MergeMessage branching strategy, while very
helpful, have pulled in very old messages from our repo that are
formatted in a way that cause the version number to be unexpectedly
high.
This changes allows configuration of commit SHAs to ignore, or strings
to ignore inside merge messages, so you can "fix" old commits in your
repo that you don't want to effect the version generation.
This is related to #466 and a possible fix for #443

Chris Maffin added 3 commits June 16, 2015 17:10
…rement version

The latest changes to the MergeMessage branching strategy, while very
helpful, have pulled in very old messages from our repo that are
formatted in a way that cause the version number to be unexpectedly
high.
This changes allows configuration of commit SHAs to ignore, or strings
to ignore inside merge messages, so you can "fix" old commits in your
repo that you don't want to effect the version generation.
This is related to GitTools#466 and a possible fix for GitTools#443
@@ -42,6 +42,16 @@ private static SemanticVersion Inner(Commit mergeCommit, EffectiveConfiguration
return null;
}

if (configuration.CommitsToIgnore != null && configuration.CommitsToIgnore.Contains(mergeCommit.Sha))
Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering if we should do something a little more generic, what about bad tags or other things? Thoughts?

Copy link
Author

Choose a reason for hiding this comment

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

My thought on tags specifically is that it's pretty easy to delete/fix a bad tag, but fixing a bad commit/message from way back in the repo is nigh on impossible.

As to the larger point, how do you think that would be accomplished? Just have a ThingsToIgnore collection and just do

if(mergeCommit.Sha.In(ThingsToIgnore) || mergeCommit.Tag.In(ThingsToIgnore) || ... etc. etc.)

?

I'm not super familiar w/ how the Commit object works, so there might be a better way than that.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's true. Leave me with this, want to think it through before I put it in the config (cause then we are stuck with it).

I will merge this before the next release.

Copy link
Author

Choose a reason for hiding this comment

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

Sounds good!

@JakeGinnivan
Copy link
Contributor

I am wondering if we should add something to the gitversion init helpers. Something along the lines of:

  • Solve GitVersion generating the wrong version? ->
  • Ignore a particular commit or merge message:
    • List the discovered base merge messages.
  • Choose to ignore one, it adds the config

Recon it's worth it?

@JakeGinnivan
Copy link
Contributor

I can help out with the init stuff if you think it would be worth it

@JakeGinnivan
Copy link
Contributor

I have been thinking about this. I think we should just have commits-to-ignore in the config.

Then in https://github.com/GitTools/GitVersion/blob/release/3.0.0/GitVersionCore/VersionCalculation/BaseVersionCalculator.cs#L24 add another if which checks to see if the Source on that base version matches any sha's in that config.

@Sacrelicious
Copy link
Author

I'm not opposed to that, although I do have 2 caveats:

  1. if the string that's incrementing the version incorrectly is part of a branch name, it could be in a number of merge messages (merged into a feature branch, then merged into develop, then into release, then into master) resulting in a bunch of commits that would need to be excluded to prevent 1 bad version name from being used.
  2. (Unless I'm missing it) There would need to be more details available in logs/console about the commit the final version number is derived from so the user will know which commit(s) to exclude.

@Sacrelicious
Copy link
Author

And I'm definitely all for doing something w/ the init stuff.

@JakeGinnivan
Copy link
Contributor

Beta 4 has much better logs so it lists everything you would need.

Also the init configuration could have an option to exclude commits which are causing incorrect version bumps, one option could be to exclude commits with commit message. So config is simple and init has the options?

Sent from my Windows Phone


From: Chris Maffinmailto:[email protected]
Sent: ‎26/‎06/‎2015 22:51
To: GitTools/GitVersionmailto:[email protected]
Cc: Jake Ginnivanmailto:[email protected]
Subject: Re: [GitVersion] Enable config based ignoring of commits/messages that incorrectly inc… (#470)

I'm not opposed to that, although I do have 2 caveats:

  1. if the string that's incrementing the version incorrectly is part of a branch name, it could be in a number of merge messages (merged into a feature branch, then merged into develop, then into release, then into master) resulting in a bunch of commits that would need to be excluded to prevent 1 bad version name from being used.
  2. (Unless I'm missing it) There would need to be more details available in logs/console about the commit the final version number is derived from so the user will know which commit(s) to exclude.


Reply to this email directly or view it on GitHubhttps://github.com//pull/470#issuecomment-115900513.

@mauroservienti
Copy link

I just faced this while trying to add GitVersion to an existing repo with a legacy history. What happened is that existing TAGs were causing GitVersion to generate a wrong SemVer version.
In my scenario, an optimal setting would be something like IgnoreBeforeSHA XYZ.

@JakeGinnivan
Copy link
Contributor

Ignore before a time would be better than a sha, otherwise it needs another scan of the repo to find all sha's which are before a specific sha. At least specific shas are a simple equality check.

@gep13
Copy link
Member

gep13 commented Jul 1, 2015

👍 for ignore before a time.

@mauroservienti
Copy link

Time works for me as well

@asbjornu
Copy link
Member

asbjornu commented Jul 9, 2015

Some sort of ignore-before-* mechanism should solve the problem I've explained in #443, so getting something like that in v3 before RTM would be great!

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.

5 participants