Skip to content

Commit message counted twice?#1138

Merged
JakeGinnivan merged 5 commits intoGitTools:masterfrom
LarsAndreasEk:unwanted-major-bump
Feb 24, 2017
Merged

Commit message counted twice?#1138
JakeGinnivan merged 5 commits intoGitTools:masterfrom
LarsAndreasEk:unwanted-major-bump

Conversation

@LarsAndreasEk
Copy link
Contributor

Hi,

git init

add some file
commit to master
tag the commit "1.0"

make a new commit to master, with message "+semver:major"

create release branch (release/2.0) from master

run GitVersion from release branch.

For the given scenario, GitVersion thinks semver should be 3.0.0-beta.1+1. I think it should be 2.0.0-beta.1+0.

I might be mistaken, but I assume this is not the intended behaviour?

What do you think?

@LarsAndreasEk
Copy link
Contributor Author

What do you think, @JakeGinnivan and @asbjornu? :)

@JakeGinnivan
Copy link
Contributor

Does it do it if you put a commit on master before taking the release branch?

Technically the commit is included in both branches and because git does not track what branches were made off what other branches there is no way to know which branch was created second.

At first look, I would not know how to approach fixing this.

@LarsAndreasEk
Copy link
Contributor Author

Hi,

I've committed a change to the test with the commit you asked. The result is the same, though.

I don't know how to approach fixing this either, but I suspect it has something to do with the base version source selected by BaseVersionCalculator at line 73-75. If I change

var calculatedBase = new BaseVersion( context, maxVersion.Version.Source, maxVersion.Version.ShouldIncrement, maxVersion.Version.SemanticVersion, baseVersionWithOldestSource.BaseVersionSource, maxVersion.Version.BranchNameOverride);
to

var calculatedBase = new BaseVersion( context, maxVersion.Version.Source, maxVersion.Version.ShouldIncrement, maxVersion.Version.SemanticVersion, maxVersion.Version.BaseVersionSource, maxVersion.Version.BranchNameOverride);

my test goes green, but 12 existing tests goes red :)

As far as I can understand, the base version source is used both to count commits and to iterate these commits to look for +semver commit messages.

@JakeGinnivan
Copy link
Contributor

Yeah, the thing is the last release is the last tag as far as gitversion is concerned. Branch points have less to do with it.

A fix for the way the code is now is to possibly remove any commit message bumps from any commits later than the merge base. Unsure how difficult that would be

When multiple base versions will result in the same semantic version, the oldest is selected for commit counting. The same base version commit is used to find intermediate commits for commit mesage increments. The attempt here is to use the oldest base version also for the semantic version such that the commit message increments are not done on a semver from another base version.
@LarsAndreasEk
Copy link
Contributor Author

I made a commit that seems to solve the issue at hand. All tests are green at least, but I'm not sure whether or not I've introduced some unwanted behavior to the code.

@LarsAndreasEk
Copy link
Contributor Author

Any thoughs, @JakeGinnivan? :)

@JakeGinnivan
Copy link
Contributor

I guess we trust our tests :) if they say all is good then it is. These sort of changes always seem to break someones workflow in some way but it makes sense to me..

To be clear, this won't fix your original issue though I don't think (if you removed the additional commit between the first message before you branch)

@LarsAndreasEk
Copy link
Contributor Author

I've committed a few tests that verify some variants. One of them is the test from the original issue. It's still green :)

@LarsAndreasEk
Copy link
Contributor Author

LarsAndreasEk commented Jan 30, 2017

Any hope getting this merged to master? :) @JakeGinnivan

@JakeGinnivan JakeGinnivan merged commit f554e4a into GitTools:master Feb 24, 2017
@JakeGinnivan
Copy link
Contributor

Thanks for this @LarsAndreasEk, good improvement

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.

2 participants