forked from GitTools/GitVersion
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathVersionInMergedBranchNameScenarios.cs
More file actions
98 lines (80 loc) · 3.35 KB
/
VersionInMergedBranchNameScenarios.cs
File metadata and controls
98 lines (80 loc) · 3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using GitVersion.Configuration;
using GitVersion.Core.Tests.Helpers;
using LibGit2Sharp;
namespace GitVersion.Core.Tests.IntegrationTests;
[TestFixture]
public class VersionInMergedBranchNameScenarios : TestBase
{
[Test]
public void TakesVersionFromNameOfReleaseBranch()
{
using var fixture = new BaseGitFlowRepositoryFixture("1.0.0");
fixture.CreateAndMergeBranchIntoDevelop("release/2.0.0");
fixture.AssertFullSemver("2.1.0-alpha.2");
}
[Test]
public void DoesNotTakeVersionFromNameOfNonReleaseBranch()
{
using var fixture = new BaseGitFlowRepositoryFixture("1.0.0");
fixture.CreateAndMergeBranchIntoDevelop("pull-request/improved-by-upgrading-some-lib-to-4.5.6");
fixture.CreateAndMergeBranchIntoDevelop("hotfix/downgrade-some-lib-to-3.2.1-to-avoid-breaking-changes");
fixture.AssertFullSemver("1.1.0-alpha.5");
}
[TestCase("release")]
[TestCase("hotfix")]
public void DoesNotTakeVersionFromBranchWithAccidentalVersion(string branch)
{
using var fixture = new EmptyRepositoryFixture();
fixture.MakeATaggedCommit("1.0.0");
fixture.BranchTo($"{branch}/downgrade-some-lib-to-3.2.1");
fixture.MakeACommit();
fixture.Checkout("main");
fixture.MergeNoFF($"{branch}/downgrade-some-lib-to-3.2.1");
fixture.AssertFullSemver("1.0.1-2");
}
[Test]
public void TakesVersionFromNameOfBranchThatIsReleaseByConfig()
{
var configuration = GitFlowConfigurationBuilder.New
.WithBranch("support", builder => builder.WithIsReleaseBranch(true))
.Build();
using var fixture = new BaseGitFlowRepositoryFixture("1.0.0");
fixture.CreateAndMergeBranchIntoDevelop("support/2.0.0");
fixture.AssertFullSemver("2.1.0-alpha.2", configuration);
}
[Test]
public void TakesVersionFromNameOfRemoteReleaseBranchInOrigin()
{
using var fixture = new RemoteRepositoryFixture();
fixture.BranchTo("release/2.0.0");
fixture.MakeACommit();
Commands.Fetch(fixture.LocalRepositoryFixture.Repository, fixture.LocalRepositoryFixture.Repository.Network.Remotes.First().Name, [], new(), null);
fixture.LocalRepositoryFixture.MergeNoFF("origin/release/2.0.0");
fixture.LocalRepositoryFixture.AssertFullSemver("2.0.0-7");
}
[Test]
public void DoesNotTakeVersionFromNameOfRemoteReleaseBranchInCustomRemote()
{
if (SysEnv.OSVersion.Platform == PlatformID.Win32NT)
{
Assert.Ignore("Test ignored on Windows - LibGitSharp 0.31.0 fails");
}
using var fixture = new RemoteRepositoryFixture();
fixture.LocalRepositoryFixture.Repository.Network.Remotes.Rename("origin", "upstream");
fixture.BranchTo("release/2.0.0");
fixture.MakeACommit();
fixture.LocalRepositoryFixture.Fetch("upstream");
fixture.LocalRepositoryFixture.MergeNoFF("upstream/release/2.0.0");
fixture.LocalRepositoryFixture.AssertFullSemver("0.0.1-7");
}
}
internal static class BaseGitFlowRepositoryFixtureExtensions
{
public static void CreateAndMergeBranchIntoDevelop(this BaseGitFlowRepositoryFixture fixture, string branchName)
{
fixture.BranchTo(branchName);
fixture.MakeACommit();
fixture.Checkout("develop");
fixture.MergeNoFF(branchName);
}
}