question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GitVersion not incrementing as expected on mainline mode

See original GitHub issue

Describe the bug We are not getting build versions as desired when using mainline mode.

Our GitVersion.yml is simply

mode: Mainline

Expected Behavior

Some background: We have a master branch and a preview branch to represent release rings. We do features and fixes in features/* and fix/* branches and then merge to preview…and then finally to master.

We have CI that builds and publishes a nuget package and we use the syntax *-preview* to lock in consumers to our preview ring.

Example:

  • master is currently at 0.1.2
  • preview (currently identical to master) is at 0.1.2-preview0088
  • We create a new feature off of preview in a branch feature/something and it gets the version 0.1.3-feature-something0001
  • We merge feature/something into preview and preview gets the version 0.1.3-preview0001
  • We merge preview into master and master gets the version 0.1.3
  • Repeat the process

Actual Behavior

This seems to work sometimes, but not others, and when it doesn’t work, it is very difficult to get things re-aligned.

  • preview (currently identical to master) is at 0.1.2-preview0088
  • We create a new feature off of preview in a branch feature/somethingnew and it gets the version 0.1.2-feature-somethingnew0001

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
asbjornucommented, Oct 26, 2021
0reactions
HHobeckcommented, Mar 20, 2023

Please tak a look to the following integration test which I have been executed on current main branch:

[Test]
public void JustATestFor2888()
{
    var configuration = GitFlowConfigurationBuilder.New
        .WithVersioningMode(VersioningMode.Mainline)
        .WithBranch("develop", _ => _
            .WithRegularExpression("^preview$")
            .WithVersioningMode(VersioningMode.ContinuousDeployment)
            .WithIncrement(IncrementStrategy.Patch)
            .WithLabel("preview")
        )
        .WithBranch("feature", _ => _
            .WithVersioningMode(VersioningMode.ContinuousDeployment)
            .WithIncrement(IncrementStrategy.Patch)
            .WithLabel("{BranchName}")
        )
        .Build();

    using var fixture = new EmptyRepositoryFixture("main");

    fixture.MakeATaggedCommit("0.1.2");

    fixture.BranchTo("preview");
    fixture.BranchTo("feature/something");
    fixture.MakeACommit();

    // ✅ succeeds as expected
    fixture.AssertFullSemver("0.1.3-something.1", configuration);

    fixture.MakeACommit();

    // ✅ succeeds as expected
    fixture.AssertFullSemver("0.1.3-something.2", configuration);

    fixture.Checkout("preview");
    fixture.MergeNoFF("feature/something");
    fixture.Remove("feature/something");

    // ✅ succeeds as expected
    fixture.AssertFullSemver("0.1.3-preview.3", configuration);

    fixture.Checkout("main");
    fixture.MergeNoFF("preview");

    // ✅ succeeds as expected
    fixture.AssertFullSemver("0.1.3", configuration);

    fixture.ApplyTag("0.1.3");

    // ✅ succeeds as expected
    fixture.AssertFullSemver("0.1.3", configuration);
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

GitVersion configuration is not incrementing
I included it just to make sure I'm using GitVersion and GitFlow in the intended way. require "git" def new_feature_branch i g =...
Read more >
Version Incrementing
If you are using GitFlow then builds off the develop branch will actually increment on every commit. This is known in GitVersion as...
Read more >
Configuration
Used to tell GitVersion not to increment when in Mainline development mode. Default \+semver:\s?(none|skip) , which will match occurrences of +semver: none ...
Read more >
How to use GitVersion to get sensible versioning
Just like we saw on the develop branch, a part of the version increments with each commit on that branch. But since adding...
Read more >
Mainline Development
If you do not want GitVersion to treat a commit or a pull request as a release and increment the version you can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found