GitVersion
GitVersion copied to clipboard
[Bug] Version not generated correct when creating a feature branch from a develop branch
Describe the bug Hi there. I'm using the GitFlow branching strategy descripted on this page https://gitversion.net/docs/learn/branching-strategies/gitflow/examples. Because I want to ensure the stability of the develop direct committing is not allowed. Thus I need to go via feature branches and got an unexpected version generation on the following scenario:
[Test]
public void __Just_A_Test__()
{
using var fixture = new EmptyRepositoryFixture();
fixture.Repository.MakeATaggedCommit("1.0.0");
fixture.BranchTo("develop");
fixture.Repository.MakeACommit();
fixture.Checkout("main");
fixture.Repository.MakeACommit();
fixture.Checkout("develop");
fixture.BranchTo("feature/just-a-test");
fixture.MergeNoFF("main");
fixture.Repository.MakeACommit();
var configuration = new Config()
{
Branches = new Dictionary<string, BranchConfig>()
{
{ "release", new BranchConfig() { TracksReleaseBranches = true } }
}
};
fixture.AssertFullSemver("1.0.1-just-a-test.1+4", configuration); // expected 1.1.0
}
That produces the following repository:
* 1d22aeb 51 minutes ago (HEAD -> feature/just-a-test)
* cb3fd3c 53 minutes ago
|\
| * 3df53ce 54 minutes ago (main)
* | e2ca7c9 56 minutes ago (develop)
|/
* 46ab60b 58 minutes ago (tag: 1.0.0)
with following commit messages:

Expected Behavior
Git Version should generate the semantic version 1.1.0 on feature branch just-a-test in this scenario.
Actual Behavior
The semantic version 1.0.1 will be generated.
Possible Fix
I'm not sure if it is a bug or I have misconfigured something.
Steps to Reproduce
Please take look to the test steps above
Context
I'm using the latest version of GitVersion 5.10.1. My build and deployment pipelines are in AzureDevOps but I can reproduce it locally.
Your Environment
- Version Used: 5.10.1
- Operating System is Windows 10
- Link to your project: n/a
- Link to your CI build (if appropriate): n/a
I believe the problem is that you don't have any commits on develop and feature/just-a-test. If I add commits to the branches, I get a result closer to your expectation:
[Test]
public void __Just_A_Test__()
{
using var fixture = new EmptyRepositoryFixture();
fixture.Repository.MakeATaggedCommit("1.0.0");
fixture.BranchTo("develop");
fixture.Repository.MakeACommit();
fixture.Checkout("main");
fixture.Repository.MakeACommit();
fixture.Checkout("develop");
fixture.Repository.MakeACommit();
fixture.BranchTo("feature/just-a-test");
fixture.Repository.MakeACommit();
fixture.MergeNoFF("main");
fixture.Repository.MakeACommit();
var configuration = new Config()
{
Branches = new Dictionary<string, BranchConfig>()
{
{ "release", new BranchConfig() { TracksReleaseBranches = true } }
}
};
fixture.AssertFullSemver("1.1.0-just-a-test.1+6", configuration);
}
This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs.
The problem is clear of course git-version doesn’t know which branch the right branch is to use. Because we have two parents on the one hand the main and on the other hand the develop branch. GitVersion takes properly the branch which was least committed. But is this behavior correct? Your proposal gives me the correct number but from the ci pipeline point of view it is not possible because the develop branch is restricted to check-in directly. Thus everything must go via a PR to ensure the stability of the branch. This scenario makes sense, doesn't it?
This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs.
This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs.
The trick is to specify the feature branch with increment minor not inherit.
:tada: This issue has been resolved in version 6.0.0-beta.6 :tada: The release is available on:
Your GitReleaseManager bot :package::rocket: