Skip to content

Commit c3bd698

Browse files
committed
Add support branch GitFlow test
1 parent 9ff7c69 commit c3bd698

File tree

4 files changed

+59
-0
lines changed

4 files changed

+59
-0
lines changed

GitVersionCore.Tests/GitVersionCore.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
<Compile Include="GitDirFinderTests.cs" />
7171
<Compile Include="Fixtures\BaseGitFlowRepositoryFixture.cs" />
7272
<Compile Include="IntegrationTests\GitFlow\DevelopScenarios.cs" />
73+
<Compile Include="IntegrationTests\GitFlow\SupportBranchScenarios.cs" />
7374
<Compile Include="IntegrationTests\GitFlow\MetaDataByCommitScenarios.cs" />
7475
<Compile Include="IntegrationTests\GitFlow\PatchScenarios.cs" />
7576
<Compile Include="IntegrationTests\GitFlow\ReleaseBranchTests.cs" />

GitVersionCore.Tests/Helpers/GitHelper.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ public static Commit MakeACommit(this IRepository repository, DateTimeOffset dat
1919
return repository.Commit("Test Commit", Constants.Signature(dateTimeOffset), Constants.Signature(dateTimeOffset));
2020
}
2121

22+
public static void MergeNoFF(this IRepository repository, string branch)
23+
{
24+
MergeNoFF(repository, branch, Constants.SignatureNow());
25+
}
26+
2227
public static void MergeNoFF(this IRepository repository, string branch, Signature sig)
2328
{
2429
repository.Merge(repository.FindBranch(branch), sig, new MergeOptions
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
namespace GitVersionCore.Tests.IntegrationTests.GitFlow
2+
{
3+
using LibGit2Sharp;
4+
using NUnit.Framework;
5+
6+
[TestFixture]
7+
public class SupportBranchScenarios
8+
{
9+
[Test]
10+
public void SupportIsCalculatedCorrectly()
11+
{
12+
using (var fixture = new BaseGitFlowRepositoryFixture("1.1.0"))
13+
{
14+
// Create 2.0.0 release
15+
fixture.Repository.CreateBranch("release-2.0.0").Checkout();
16+
fixture.Repository.MakeCommits(2);
17+
18+
// Merge into develop and master
19+
fixture.Repository.Checkout("master");
20+
fixture.Repository.MergeNoFF("release-2.0.0");
21+
fixture.Repository.ApplyTag("2.0.0");
22+
fixture.Repository.Checkout("develop");
23+
fixture.Repository.MergeNoFF("release-2.0.0");
24+
fixture.AssertFullSemver("2.1.0-unstable.0+0");
25+
26+
// Now lets support 1.x release
27+
fixture.Repository.Checkout("1.1.0");
28+
fixture.Repository.CreateBranch("support/1.0.0").Checkout();
29+
fixture.AssertFullSemver("1.1.0");
30+
31+
// Create release branch from support branch
32+
fixture.Repository.CreateBranch("release/1.2.0").Checkout();
33+
fixture.Repository.MakeACommit();
34+
fixture.AssertFullSemver("1.2.0-beta.1+1");
35+
36+
// Create 1.2.0 release
37+
fixture.Repository.Checkout("support/1.0.0");
38+
fixture.Repository.MergeNoFF("release/1.2.0");
39+
fixture.AssertFullSemver("1.2.0");
40+
fixture.Repository.ApplyTag("1.2.0");
41+
42+
// Create 1.2.1 hotfix
43+
fixture.Repository.CreateBranch("hotfix/1.2.1").Checkout();
44+
fixture.Repository.MakeACommit();
45+
fixture.AssertFullSemver("1.2.1-beta.1+3");
46+
fixture.Repository.Checkout("support/1.0.0");
47+
fixture.Repository.MergeNoFF("hotfix/1.2.1");
48+
fixture.AssertFullSemver("1.2.1");
49+
}
50+
}
51+
}
52+
}

GitVersionCore/GitFlow/BranchFinders/HotfixVersionFinder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ static string GetSuffix(Branch branch)
3939
{
4040
return branch.Name.TrimStart("hotfix-").TrimStart("hotfix/");
4141
}
42+
4243
void EnsureVersionIsValid(ShortVersion version, Branch branch)
4344
{
4445
if (version.Patch == 0)

0 commit comments

Comments
 (0)