Skip to content

Invalid release version after commit beetween merge release to develop #1205

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

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,45 @@ public void CommitOnDevelop_AfterReleaseBranchMergeToDevelop_ShouldNotResetCount
fixture.AssertFullSemver(config, "2.0.0-beta.5");
}
}


[Test]
public void CommitBeetweenMergeReleaseToDevelop_ShouldNotResetCount()
{
var config = new Config
{
VersioningMode = VersioningMode.ContinuousDeployment
};

using(var fixture = new EmptyRepositoryFixture())
{
fixture.Repository.MakeACommit("initial");
fixture.Repository.CreateBranch("develop");
Commands.Checkout(fixture.Repository, "develop");
fixture.Repository.CreateBranch("release-2.0.0");
Commands.Checkout(fixture.Repository, "release-2.0.0");
fixture.AssertFullSemver(config, "2.0.0-beta.0");

// Make some commits on release
var commit1 = fixture.Repository.MakeACommit();
var commit2 = fixture.Repository.MakeACommit();
fixture.AssertFullSemver(config, "2.0.0-beta.2");

// Merge release to develop - emulate commit beetween other person release commit push and this commit merge to develop
Commands.Checkout(fixture.Repository, "develop");
fixture.Repository.Merge(commit1, Generate.SignatureNow(), new MergeOptions { FastForwardStrategy = FastForwardStrategy.NoFastForward });
fixture.Repository.MergeNoFF("release-2.0.0", Generate.SignatureNow());

// Check version on release after merge to develop
Commands.Checkout(fixture.Repository, "release-2.0.0");
fixture.AssertFullSemver(config, "2.0.0-beta.2");

// Check version on release after making some new commits
fixture.Repository.MakeACommit();
fixture.Repository.MakeACommit();
fixture.AssertFullSemver(config, "2.0.0-beta.4");
Copy link
Member

Choose a reason for hiding this comment

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

Which version is produced here before your fix?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here 2.0.0-beta.3, but problem starts in previous assert (2.0.0-beta.1 instead of 2.0.0-beta.2).

}
}

public void ReleaseBranchShouldUseBranchNameVersionDespiteBumpInPreviousCommit()
{
using (var fixture = new EmptyRepositoryFixture())
Expand Down
1 change: 1 addition & 0 deletions src/GitVersionCore/GitRepoMetadataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public Commit FindMergeBase(Branch branch, Branch otherBranch)
mergeBaseAsForwardMerge = otherBranch.Commits
.SkipWhile(c => c != commitToFindCommonBase)
.TakeWhile(c => c != findMergeBase)
.OrderBy(c => c.Parents.Count())
.LastOrDefault(c => c.Parents.Contains(findMergeBase));

if (mergeBaseAsForwardMerge != null)
Expand Down