1
+ using GitVersion . Configuration ;
2
+ using LibGit2Sharp ;
3
+ using NUnit . Framework ;
4
+
5
+ [ TestFixture ]
6
+ public class GitFlowReleaseBranchTests
7
+ {
8
+ [ Test ]
9
+ public void CanTakeVersionFromReleaseBranch ( )
10
+ {
11
+ using ( var fixture = new EmptyRepositoryFixture ( new Config ( ) ) )
12
+ {
13
+ fixture . Repository . MakeATaggedCommit ( "1.0.3" ) ;
14
+ fixture . Repository . CreateBranch ( "develop" ) ;
15
+ fixture . Repository . MakeCommits ( 5 ) ;
16
+ fixture . Repository . CreateBranch ( "release-2.0.0" ) ;
17
+ fixture . Repository . Checkout ( "release-2.0.0" ) ;
18
+
19
+ fixture . AssertFullSemver ( "2.0.0-beta.1+5" ) ;
20
+ }
21
+ }
22
+
23
+ [ Test ]
24
+ public void CanTakeVersionFromReleaseBranchWithTagOverriden ( )
25
+ {
26
+ using ( var fixture = new EmptyRepositoryFixture ( new Config { ReleaseBranchTag = "rc" } ) )
27
+ {
28
+ fixture . Repository . MakeATaggedCommit ( "1.0.3" ) ;
29
+ fixture . Repository . CreateBranch ( "develop" ) ;
30
+ fixture . Repository . MakeCommits ( 5 ) ;
31
+ fixture . Repository . CreateBranch ( "release-2.0.0" ) ;
32
+ fixture . Repository . Checkout ( "release-2.0.0" ) ;
33
+
34
+ fixture . AssertFullSemver ( "2.0.0-rc.1+5" ) ;
35
+ }
36
+ }
37
+
38
+ [ Test ]
39
+ public void WhenReleaseBranchIsMergedIntoMasterVersionIsTakenWithIt ( )
40
+ {
41
+ using ( var fixture = new EmptyRepositoryFixture ( new Config ( ) ) )
42
+ {
43
+ fixture . Repository . MakeATaggedCommit ( "1.0.3" ) ;
44
+ fixture . Repository . CreateBranch ( "develop" ) ;
45
+ fixture . Repository . MakeCommits ( 1 ) ;
46
+ fixture . Repository . CreateBranch ( "release-2.0.0" ) ;
47
+ fixture . Repository . Checkout ( "release-2.0.0" ) ;
48
+ fixture . Repository . MakeCommits ( 4 ) ;
49
+ fixture . Repository . Checkout ( "master" ) ;
50
+ fixture . Repository . MergeNoFF ( "release-2.0.0" , Constants . SignatureNow ( ) ) ;
51
+
52
+ // TODO For GitHubFlow this is 2.0.0+6, why is it different
53
+ fixture . AssertFullSemver ( "2.0.0" ) ;
54
+ }
55
+ }
56
+
57
+ // TODO This test fails for GitFlow, it needs to be fixed (although in reality a support branch should be used)
58
+ [ Test , Ignore ]
59
+ public void WhenReleaseBranchIsMergedIntoMasterHighestVersionIsTakenWithIt ( )
60
+ {
61
+ using ( var fixture = new EmptyRepositoryFixture ( new Config ( ) ) )
62
+ {
63
+ fixture . Repository . MakeATaggedCommit ( "1.0.3" ) ;
64
+ fixture . Repository . CreateBranch ( "develop" ) ;
65
+ fixture . Repository . MakeCommits ( 1 ) ;
66
+
67
+ fixture . Repository . CreateBranch ( "release-2.0.0" ) ;
68
+ fixture . Repository . Checkout ( "release-2.0.0" ) ;
69
+ fixture . Repository . MakeCommits ( 4 ) ;
70
+ fixture . Repository . Checkout ( "master" ) ;
71
+ fixture . Repository . MergeNoFF ( "release-2.0.0" , Constants . SignatureNow ( ) ) ;
72
+ fixture . Repository . Checkout ( "develop" ) ;
73
+ fixture . Repository . MergeNoFF ( "release-2.0.0" , Constants . SignatureNow ( ) ) ;
74
+
75
+ fixture . Repository . CreateBranch ( "release-1.0.0" ) ;
76
+ fixture . Repository . Checkout ( "release-1.0.0" ) ;
77
+ fixture . Repository . MakeCommits ( 4 ) ;
78
+ fixture . Repository . Checkout ( "master" ) ;
79
+ fixture . Repository . MergeNoFF ( "release-1.0.0" , Constants . SignatureNow ( ) ) ;
80
+ fixture . Repository . Checkout ( "develop" ) ;
81
+ fixture . Repository . MergeNoFF ( "release-1.0.0" , Constants . SignatureNow ( ) ) ;
82
+
83
+ fixture . AssertFullSemver ( "2.0.0+11" ) ;
84
+ }
85
+ }
86
+ }
0 commit comments