You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit count resets to 0 when merge detected on branches #700
We have a case where developer A committed his changes before pulling down changes previously pushed by another developer B, he then has to pull B's changes down, merging them, before he's allowed to push his own changes. This case seems to reset the commit count to zero at the point developer A's changes are merged.
Interesting. What happens if you rebase the changes rather than merge, or is that not an option?
Sent from my Windows Phone
From: Mark Snellingmailto:[email protected]
Sent: 19/10/2015 16:58
To: GitTools/GitVersionmailto:[email protected]
Subject: [GitVersion] Commit count resets to 0 when merge detected on branches (#700)
We have a case where developer A committed his changes before pulling down changes previously pushed by another developer B, he then has to pull B's changes down, merging them, before he's allowed to push his own changes. This case seems to reset the commit count to zero at the point developer A's changes are merged.
Reply to this email directly or view it on GitHub: #700
Subject: [GitVersion] Commit count resets to 0 when merge detected on
branches (#700)
We have a case where developer A committed his changes before pulling down
changes previously pushed by another developer B, he then has to pull B's
changes down, merging them, before he's allowed to push his own changes.
This case seems to reset the commit count to zero at the point developer
A's changes are merged.
Reply to this email directly or view it on GitHub:
If I understand correctly you're having 4 branches. Master, develop, feature/epic, feature/epic-part1 where feature/epic is merged into feature/epic-part1? And you're expecting to track the develop branch?
Hi @msnelling I've tried to reproduce your issue with a test case but from my point of view it's looking ok, but I'll guess it's just me that doesn't understand your workflow?
Would you mind having a look at this commit? orjan@eab0609
Hi @orjan, Not that's not quite what I meant. We have three branches, master, develop and release/1.2.0.
The problem is when two developers are working on release/1.2.0. dev-A and dev-B are both on the same commit, then dev-B commits a change locally and pushes up to the remote, then dev-A commits a change locally and then also tries to push. dev-A's push is rejected because the remote is ahead so dev-A has to pull. This pull creates a merge point on the branch and it is at this point the commit count seems to be reset to zero.
@msnelling I think you've explained the scenario well now, but at least for future reference and perhaps also as a great illustration, I'd recommend drawing the sequence leading up to the problem you're seeing. It has proven to be quite helpful in similar discussions about GitVersion in the past.
I can confirm this behavior as well. Similar to @tpluscode, our team is merging an in progress release branch into develop to apply some fixes for in progress next release work (off of develop). GitFlow shows this as "bugfixes from rel. branch".
Inspecting the code, LibGitExtensions.FindCommitBranchWasBranchedFrom is relying on the most recent merge base. Unfortunately, this is not necessarily equivalent to where the branch was branched from. Maybe someone has a better way of finding the branch point - the only sure way I know of is to reverse iterate git show-branch --more=XXX develop release/1.2.3 and look for the commit previous to the first divergence point. The problem is choosing a value for XXX. There has to be a better way?
Also of note:
Bugfix merges as described above ends up prematurely bumping the Develop version since it sees interprets the canned merge commit comment in its MergeMessageStrategy.
Fairly sure this resetting also happens when forward integrating develop into a feature branch (by way of merge instead of rebase).
I also added an AssertSemVer to show the premature version bump on develop. Not sure how people feel about this, I see discussions (#695) about bumping it when the release branch shows up.
//!! develop bumped prematurely - we weren't done the release yet
fixture.AssertFullSemver("2.1.0-unstable.0"); //was 1.1.0-unstable.1 before the merge
I think going the way of #695 is the way to go, if you need to continue working on 1.1.x then take a support/1.1.0 branch and use that?
Ok, so now when you forward merge a release branch the commit count will no longer reset. This doesn't fix the premature bumping, but I don't think we can fix that.
Gonna close this, if these are follow up issues or the fix doesn't work for other scenarios let me know or open up a new issue referencing this one.
The branch release/1.4 is a branch from 9217f49575afd28dddd792137ad101f89166dd14
GitVersion selected a66691e3e173ae07a1cb086e37132cb1b9d2a0d5 as the source
Activity
gep13 commentedon Oct 19, 2015
Interesting. What happens if you rebase the changes rather than merge, or is that not an option?
Sent from my Windows Phone
From: Mark Snellingmailto:[email protected]
Sent: 19/10/2015 16:58
To: GitTools/GitVersionmailto:[email protected]
Subject: [GitVersion] Commit count resets to 0 when merge detected on branches (#700)
We have a case where developer A committed his changes before pulling down changes previously pushed by another developer B, he then has to pull B's changes down, merging them, before he's allowed to push his own changes. This case seems to reset the commit count to zero at the point developer A's changes are merged.
Reply to this email directly or view it on GitHub:
#700
msnelling commentedon Oct 19, 2015
Hi Gary, Unfortunately rebasing isn't an option for us.
orjan commentedon Oct 19, 2015
Hi Mark! Are you pulling from develop or master?
On Oct 19, 2015 6:23 PM, "Mark Snelling" [email protected] wrote:
msnelling commentedon Oct 19, 2015
Actually we're pulling from a feature branch (using GitFlow).
orjan commentedon Oct 19, 2015
Just to make sure that I understand the flow.
If I understand correctly you're having 4 branches. Master, develop, feature/epic, feature/epic-part1 where feature/epic is merged into feature/epic-part1? And you're expecting to track the develop branch?
orjan commentedon Oct 20, 2015
Hi @msnelling I've tried to reproduce your issue with a test case but from my point of view it's looking ok, but I'll guess it's just me that doesn't understand your workflow?
Would you mind having a look at this commit?
orjan@eab0609
msnelling commentedon Oct 20, 2015
Hi @orjan, Not that's not quite what I meant. We have three branches, master, develop and release/1.2.0.
The problem is when two developers are working on release/1.2.0. dev-A and dev-B are both on the same commit, then dev-B commits a change locally and pushes up to the remote, then dev-A commits a change locally and then also tries to push. dev-A's push is rejected because the remote is ahead so dev-A has to pull. This pull creates a merge point on the branch and it is at this point the commit count seems to be reset to zero.
asbjornu commentedon Oct 20, 2015
@msnelling I think you've explained the scenario well now, but at least for future reference and perhaps also as a great illustration, I'd recommend drawing the sequence leading up to the problem you're seeing. It has proven to be quite helpful in similar discussions about GitVersion in the past.
msnelling commentedon Oct 20, 2015
Ok, I think I've created a test which reflects the use case
I have also created a GitHub repo that demonstrates the conditions. https://github.com/msnelling/GitVersionTest/tree/release/2.0.0 should point to the head of the release branch that shows the version as 2.0.0-beta.0
tpluscode commentedon Nov 16, 2015
👍
We're seeing the same behaviour. When release branch i merged to back develop, its counter resets to 0
Tungsten78 commentedon Dec 4, 2015
👍
I can confirm this behavior as well. Similar to @tpluscode, our team is merging an in progress release branch into develop to apply some fixes for in progress next release work (off of develop). GitFlow shows this as "bugfixes from rel. branch".
Inspecting the code, LibGitExtensions.FindCommitBranchWasBranchedFrom is relying on the most recent merge base. Unfortunately, this is not necessarily equivalent to where the branch was branched from. Maybe someone has a better way of finding the branch point - the only sure way I know of is to reverse iterate
git show-branch --more=XXX develop release/1.2.3and look for the commit previous to the first divergence point. The problem is choosing a value for XXX. There has to be a better way?Also of note:
Tungsten78 commentedon Dec 4, 2015
Found a unit test trying to cover this scenario, however the problem was that the reset doesn't happen until the next commit.
I've amended it and it now fails: unit test.
I also added an AssertSemVer to show the premature version bump on develop. Not sure how people feel about this, I see discussions (#695) about bumping it when the release branch shows up.
JakeGinnivan commentedon Jan 17, 2016
@Tungsten78 not sure how to fix the first one:
I think going the way of #695 is the way to go, if you need to continue working on 1.1.x then take a
support/1.1.0branch and use that?No longer resets commit count when branch is forward merged
JakeGinnivan commentedon Jan 17, 2016
Ok, so now when you forward merge a release branch the commit count will no longer reset. This doesn't fix the premature bumping, but I don't think we can fix that.
Gonna close this, if these are follow up issues or the fix doesn't work for other scenarios let me know or open up a new issue referencing this one.
tpluscode commentedon Jan 18, 2016
👍 Is there a release coming?
taborda commentedon Mar 15, 2016
Hi @JakeGinnivan
I'm still experiencing this problem when a merge is being done in a release branch like @msnelling said with the two devs committing.
If it helps, here is the log:
gitversion_branch_merge_resets_commit_count.txt
There was a merge in the release/1.4 branch with the message:
Merge branch 'release/1.4' of https://git-srv.local/taborda/test into release/1.4
The commit count reset after this.
The branch release/1.4 is a branch from 9217f49575afd28dddd792137ad101f89166dd14
GitVersion selected a66691e3e173ae07a1cb086e37132cb1b9d2a0d5 as the source
taborda commentedon Mar 17, 2016
I think this is only happening on the first merge on the branch.
After that, it is not resetting the commit count on each merge. But still, it is counting from the last merge, that is when it was reset.
aryak007 commentedon Dec 14, 2019
Guys, I'm actually facing something similar. Can you please take a look into this - #1992?