GitVersion icon indicating copy to clipboard operation
GitVersion copied to clipboard

[Bug] SemVer of a feature branch started from a release branch gets decremented

Open ni-jsuchocki opened this issue 3 years ago • 8 comments

Describe the bug

Hello! We are using GitVersion with the GitFlow branching scheme. I'd expect that the feature branch started from a release branch has the same SemVer as the parent release branch.

Expected Behavior

SemVer of a commit on a feature branch is the same as the SemVer of a parent release branch.

Actual Behavior

SemVer gets decremented to the previous release version.

Steps to Reproduce

[Test]
public void ShouldPickUpReleaseVersionAfterCreatedFromRelease()
{
    using var fixture = new EmptyRepositoryFixture();

    // Create develop and a release branch
    fixture.MakeATaggedCommit("1.0.0");
    fixture.MakeACommit();
    fixture.BranchTo("develop");
    fixture.BranchTo("release/1.1.0");
    fixture.MakeACommit();
    fixture.AssertFullSemver("1.1.0-beta.1+1");


    // Create a feature branch from the release/1.1.0 branch
    fixture.BranchTo("feature/test");
    fixture.MakeACommit();
    fixture.AssertFullSemver("1.1.0-test.1+1");  // this fails (returns 1.0.0-test.1+3)
}

Context

I know this can be fixed by setting tracks-release-branches: true for the release branch type, but this has other consequences as well - for example if a release/2.0.0 branch is started in the same repo, the SemVer of a build from a feature branch will be 2.0.0 even if its parent branch is release/1.1.0.

Also looking at the docs for track-release-branches - Indicates this branch config represents develop in GitFlow. - I am wary to change it for release branches.

It looks as it should be the default behaviour for me, but am I missing some other configuration options that would change this?

Your Environment

  • Version Used: The unit test above was tested with main at 5.10.4-beta.1+41.Branch.main.Sha.68604754376c7df1d7a378a3a29fb92d55dd3013, same behavior is observed in our CI where 5.8.2 is installed
  • Operating System and version: Mac11 locally, Windows 10 in CI

ni-jsuchocki avatar Jul 12 '22 13:07 ni-jsuchocki

feature/* branches should be created from develop, not from a release/* branch. If you change that, I think you'll get more of the inteded behaviour.

asbjornu avatar Aug 27 '22 22:08 asbjornu

So the idea is that stabilizing a release/* branch should be done by direct pushes?

ni-jsuchocki avatar Aug 29 '22 08:08 ni-jsuchocki

Yes, or by merging more feature/* branches into develop and then rebasing the release/* branch on develop or merging develop into the release/* branch.

asbjornu avatar Aug 29 '22 20:08 asbjornu

Could this be considered a future improvement? It is not explicitly stated how bugfixes should be done on release/* branches in GitFlow, but having the ability to go through a PR with doing such a fix would be nice. Merging develop into release/* is not always an option, as more development could have already happened there.

ni-jsuchocki avatar Aug 31 '22 12:08 ni-jsuchocki

It not rare to have rules on projects that only allow changes through pull requests. Especially on release branches as they tend to generate releasable artifacts.

Also, as @ni-jsuchocki said, if a team is big enough, it is also common to have new development on develop while stabilization work is happening on the release branch. So we might not want the new changes from develop while stabilizing the release branch.

ni-fgenois avatar Aug 31 '22 12:08 ni-fgenois

Sure, I understand that. But I don't see a way to tell GitVersion to have feature/* branches both track develop and release/* branches simultaneously. At least not without a pull request that walks the commit tree until it finds a release/* branch and then somehow decides that "yes, this is where I'm going to derive my version number from".

An alternative would be to name the release-stabilizing branches differently from feature/* and configure those to track release/* somehow. I've never done that myself, so I'm not sure whether it's going to work, but it's worth trying.

asbjornu avatar Sep 01 '22 08:09 asbjornu

Please see the discussion in #3101.

asbjornu avatar Sep 02 '22 18:09 asbjornu

Please take a look and tell me if you are agree with this test (see integration test here). Two commits have been pushed after you entered the beta phase that's why +2 IMO

HHobeck avatar Sep 16 '22 12:09 HHobeck

Hi @HHobeck, sorry for not reaching out earlier but thanks a lot for the changes you've done here! I finally found some time to play around with the current state of the code and your changes seem to really improve on a couple of issues we were encountering earlier! Can't wait for the 6.0 release :)

ni-jsuchocki avatar Dec 16 '22 15:12 ni-jsuchocki

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

Your GitReleaseManager bot :package::rocket:

arturcic avatar Dec 22 '22 15:12 arturcic