Skip to content

Commit

Permalink
Test for issue 2786
Browse files Browse the repository at this point in the history
  • Loading branch information
koershov committed Jul 27, 2021
1 parent 1680a89 commit 35b9042
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 0 deletions.
122 changes: 122 additions & 0 deletions src/GitVersion.Core.Tests/IntegrationTests/MainlineDevelopmentMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,128 @@ public void SupportBranches()
fixture.AssertFullSemver("1.0.5-PullRequest0007.3", this.config);
}

[Test]
public void HotfixBranchesWithTaggedCommitsOnMain()
{
using var fixture = new EmptyRepositoryFixture();
var configBumpMinor = new Config()
{
VersioningMode = VersioningMode.Mainline,
Increment = IncrementStrategy.Minor,
Branches =
{
{
Config.MainBranchKey,
new BranchConfig
{
Regex = Config.MainBranchRegex,
SourceBranches = new HashSet<string>
{
Config.DevelopBranchKey,
Config.ReleaseBranchKey
},
Tag = string.Empty,
PreventIncrementOfMergedBranchVersion = true,
Increment = IncrementStrategy.Minor,
IsMainline = true,
PreReleaseWeight = 55000,
}
},
{
Config.HotfixBranchKey,
new BranchConfig
{
Tag = ""
}
}
}
};

fixture.Repository.MakeACommit("1");
fixture.MakeATaggedCommit("1.0.0");

fixture.MakeACommit(); // 1.1.0
fixture.AssertFullSemver("1.1.0", configBumpMinor);
fixture.ApplyTag("1.1.0");
fixture.AssertFullSemver("1.1.0", configBumpMinor);

fixture.BranchTo("hotfix/may");
fixture.AssertFullSemver("1.1.1", configBumpMinor);

// Move main on
fixture.Checkout(MainBranch);
fixture.MakeACommit();
fixture.AssertFullSemver("1.2.0", configBumpMinor);

// Continue on hotfix
fixture.Checkout("hotfix/may");
fixture.MakeACommit(); // 1.2.1
fixture.AssertFullSemver("1.1.1", configBumpMinor);
}

[Test]
public void HotfixBranchesWithTaggedCommitsOnHotfix()
{
using var fixture = new EmptyRepositoryFixture();
var configBumpMinor = new Config()
{
VersioningMode = VersioningMode.Mainline,
Increment = IncrementStrategy.Minor,
Branches =
{
{
Config.MainBranchKey,
new BranchConfig
{
Regex = Config.MainBranchRegex,
SourceBranches = new HashSet<string>
{
Config.DevelopBranchKey,
Config.ReleaseBranchKey
},
Tag = string.Empty,
PreventIncrementOfMergedBranchVersion = true,
Increment = IncrementStrategy.Minor,
IsMainline = true,
PreReleaseWeight = 55000,
}
},
{
Config.HotfixBranchKey,
new BranchConfig
{
Tag = ""
}
}
}
};

fixture.Repository.MakeACommit("1");
fixture.MakeATaggedCommit("1.0.0");

fixture.MakeACommit(); // 1.1.0
fixture.AssertFullSemver("1.1.0", configBumpMinor);
fixture.ApplyTag("1.1.0");
fixture.AssertFullSemver("1.1.0", configBumpMinor);
fixture.MakeACommit(); // 1.2.0
fixture.AssertFullSemver("1.2.0", configBumpMinor);

fixture.BranchTo("hotfix/may");
fixture.AssertFullSemver("1.2.1", configBumpMinor);

// Move main on
fixture.Checkout(MainBranch);
fixture.MakeACommit();
fixture.AssertFullSemver("1.3.0", configBumpMinor);

// Continue on hotfix
fixture.Checkout("hotfix/may");
fixture.MakeACommit(); // 1.2.1
fixture.MakeATaggedCommit("1.2.2");
fixture.MakeACommit(); // 1.2.3
fixture.AssertFullSemver("1.2.3", configBumpMinor);
}

[Test]
public void VerifyForwardMerge()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ private ICommit FindMergeBaseBeforeForwardMerge(ICommit? baseVersionSource, IBra
{
var mergeBase = this.repositoryStore.FindMergeBase(context.CurrentCommit!, mainline.Tip!);
var mainlineCommitLog = this.repositoryStore.GetMainlineCommitLog(baseVersionSource, mainline.Tip).ToList();
//var mainlineCommitLog = this.repositoryStore.GetMainlineCommitLog(mergeBase.Parents.FirstOrDefault(), mainline.Tip).ToList();

// find the mainline commit effective for versioning the current branch
mainlineTip = GetEffectiveMainlineTip(mainlineCommitLog, mergeBase, mainline.Tip);
Expand Down

0 comments on commit 35b9042

Please sign in to comment.