Skip to content
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

[Bug] Merging develop to release branch makes alpha version jump back #3154

Closed
franknarf8 opened this issue Jul 18, 2022 · 3 comments · Fixed by #3190
Closed

[Bug] Merging develop to release branch makes alpha version jump back #3154

franknarf8 opened this issue Jul 18, 2022 · 3 comments · Fixed by #3190
Labels
Milestone

Comments

@franknarf8
Copy link

franknarf8 commented Jul 18, 2022

Describe the bug

Hello again dear GitVersion maintainers :)

When getting the changes from the develop branch on top of an existing release branch, the commit counting of develop drops as the Merge Base commit changes.

Expected Behavior

The commit counting on develop should never drop, otherwise this generates overlapping build numbers.

Actual Behavior

    [Test]
    public void MergingDevelopToReleaseBranchShouldNotResetCommitCounterOfDevelop()
    {
        using var fixture = new EmptyRepositoryFixture();
        fixture.MakeATaggedCommit("2.0.0");
        fixture.BranchTo("release/3.0.0");
        fixture.BranchTo("develop");
        fixture.Repository.MakeCommits(8); // on develop
        fixture.AssertFullSemver("3.1.0-alpha.8");

        // work on a beta release
        fixture.Checkout("release/3.0.0");
        fixture.Repository.MakeCommits(20);
        fixture.AssertFullSemver("3.0.0-beta.1+20");

        // Finalize beta
        fixture.ApplyTag("3.0.0-beta.1");
        fixture.AssertFullSemver("3.0.0-beta.1");

        // and start new one
        fixture.Repository.MakeCommits(2);
        // Counting commits from MergeBase of develop and release/3.0.0
        // counting from the 3.0.0-beta.1 would be better, but this is still ok
        fixture.AssertFullSemver("3.0.0-beta.2+22"); // 3.0.0-beta.2+2 would be better

        // we now want to get the changes from develop onto release/3.0.0 for the 2nd beta
        fixture.MergeNoFF("develop");
        fixture.AssertFullSemver("3.0.0-beta.2+23"); // Ok cool

        // ok, let's look at develop
        fixture.Checkout("develop");
        // eh, wait what? Why has the version jumped back from 3.1.0 to 2.1.0?!!
        fixture.AssertFullSemver("2.1.0-alpha.8");
        // eh, ok, an extra commit should fix that
        fixture.MakeACommit();
        // what?! Why do we reset back to alpha.1?! This will collide with a previous versions!!!
        fixture.AssertFullSemver("3.1.0-alpha.1"); // expecting 3.1.0-alpha.9
    }

Workaround

    [Test]
    public void WorkaroundThisBehaviorByUsingDifferentVersions()
    {
        using var fixture = new EmptyRepositoryFixture();
        fixture.MakeATaggedCommit("2.0.0");
        fixture.BranchTo("master");
        fixture.BranchTo("release/3.0.0");
        fixture.BranchTo("develop");
        fixture.Repository.MakeCommits(8); // on develop
        fixture.AssertFullSemver("3.1.0-alpha.8");

        // work on a beta release
        fixture.Checkout("release/3.0.0");
        fixture.Repository.MakeCommits(20);
        fixture.AssertFullSemver("3.0.0-beta.1+20");

        // finalize the 3.0.0 beta
        fixture.Checkout("develop");
        fixture.MergeNoFF("release/3.0.0");
        fixture.Repository.Branches.Remove("release/3.0.0");
        fixture.AssertFullSemver("3.1.0-alpha.29");

        // start the 3.0.1 beta
        fixture.BranchTo("release/3.0.1");
        fixture.Repository.MakeCommits(10);
        fixture.AssertFullSemver("3.0.1-beta.1+10");

        // finalize the 3.0.1 beta and release it
        fixture.Checkout("develop");
        fixture.MergeNoFF("release/3.0.1");
        fixture.Repository.Branches.Remove("release/3.0.1");
        fixture.AssertFullSemver("3.1.0-alpha.40");
        fixture.Checkout("master");
        fixture.MergeNoFF("develop");
        fixture.AssertFullSemver("3.0.1+12");
    }

Context

Creating a beta tag (e.g. 3.0.0-beta.1) is then only useful if the develop and the release branches are completely independent.

I'm not sure how we could implement a fix for this. Finding the base commit from which the metadata value is currently calculated using the vanilla MergeBase functionality of git, which finds the shortest intersection of 2 branches.

Any ideas?

@franknarf8 franknarf8 added the bug label Jul 18, 2022
@franknarf8 franknarf8 changed the title [Bug] Merging develop to release branch makes alpha version jump back Jul 19, 2022
@franknarf8 franknarf8 changed the title Merging develop to release branch makes alpha version jump back [Bug] Merging develop to release branch makes alpha version jump back Jul 20, 2022
@asbjornu
Copy link
Member

asbjornu commented Sep 3, 2022

I think you may be affected by #3041.

@HHobeck
Copy link
Contributor

HHobeck commented Sep 21, 2022

I have tested your integration test on the PR #3190 and it's working like you would expecting it IMO.

@arturcic
Copy link
Member

🎉 This issue has been resolved in version 6.0.0 🎉
The release is available on:

Your GitReleaseManager bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants