-
Notifications
You must be signed in to change notification settings - Fork 652
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] Mainline mode breaks hotfix version when commit is tagged #2786
Comments
While this does sound like a bug, I wonder why you would tag the |
We just tag every commit on which we run the build. But even if we don't, there still gonna be an issue when the parent commit of the hotfix branch is tagged (example 2) |
Are you able to submit this as a (failing) test in a PR? |
I've already provided 2 tests here: #2787 |
Ah, sorry. I haven't had time to investigate. |
Hi @asbjornu, any update on this one? It does look like a bug and quite unpleasant one. |
The The following configuration is something which might be suit better for your use case: [Test]
public void HotfixScenarioWithVersioningModeMainline()
{
var configuration = GitFlowConfigurationBuilder.New
.WithVersioningMode(VersioningMode.Mainline)
.WithBranch("main", _ => _.WithIncrement(IncrementStrategy.Minor))
.WithBranch("hotfix", _ => _.WithIncrement(IncrementStrategy.Patch))
.Build();
using var fixture = new EmptyRepositoryFixture("main");
fixture.MakeATaggedCommit("1.0.0");
// ✅ succeeds as expected
fixture.AssertFullSemver("1.0.0", configuration);
fixture.MakeACommit();
// ✅ succeeds as expected
fixture.AssertFullSemver("1.1.0", configuration);
fixture.MakeACommit();
// ✅ succeeds as expected
fixture.AssertFullSemver("1.2.0", configuration);
fixture.ApplyTag("1.2.0");
// ✅ succeeds as expected
fixture.AssertFullSemver("1.2.0", configuration);
fixture.BranchTo("hotfix/1.2.1");
fixture.MakeACommit();
// ✅ succeeds as expected
fixture.AssertFullSemver("1.2.1-beta.1+1", configuration);
fixture.MakeACommit();
// ✅ succeeds as expected
fixture.AssertFullSemver("1.2.1-beta.1+2", configuration);
fixture.ApplyTag("1.2.1-beta.1");
// ✅ succeeds as expected
fixture.AssertFullSemver("1.2.1-beta.1", configuration);
fixture.MakeACommit();
// ✅ succeeds as expected
fixture.AssertFullSemver("1.2.1-beta.2+1", configuration);
fixture.Checkout("main");
fixture.MergeNoFF("hotfix/1.2.1");
// ✅ succeeds as expected
fixture.AssertFullSemver("1.2.1", configuration);
fixture.ApplyTag("1.2.1");
// ✅ succeeds as expected
fixture.AssertFullSemver("1.2.1", configuration);
fixture.MakeACommit();
// ✅ succeeds as expected
fixture.AssertFullSemver("1.3.0", configuration);
} |
Describe the bug
When I use mainline mode with master and hotfix branch it works fine unless I start tagging every commit.
Imagine a hotfix branch is branched out from the mainline at version 1.2.0. From that point, every commit on that branch should increment only the patch version. But if one of the commits on hotfix was tagged with current version the next version calculation will be broken (the minor version will be affected by an unrelated commit on mainline)
Here's an example how the git structure for that case looks like
The same thing happens when the commit where the hotfix branch was branched of is tagged
Expected Behavior
First example, the version should be "1.2.3"
Second example, the version should be "1.1.1"
Actual Behavior
First example, the version should is "1.3.1"
Second example, the version should be "1.2.1"
Possible Fix
It feels like mainlineCommitLog should include also the commit where the current branch was branched off. In FindMergeBaseBeforeForwardMerge method
Steps to Reproduce
Tests are here #2787
Context
Our strategy is very simple. Each commit on main should increment minor. Each commit on hotfix should increment patch.
The text was updated successfully, but these errors were encountered: