3
3
using GitVersionCore . Tests ;
4
4
using LibGit2Sharp ;
5
5
using NUnit . Framework ;
6
+ using GitVersion ;
6
7
7
8
[ TestFixture ]
8
9
public class HotfixBranchScenarios : TestBase
@@ -123,4 +124,116 @@ public void PatchOlderReleaseExample()
123
124
fixture . AssertFullSemver ( "2.1.0-alpha.7" ) ;
124
125
}
125
126
}
127
+
128
+ /// <summary>
129
+ /// Create a feature branch from a hotfix branch, and merge back, then delete it
130
+ /// </summary>
131
+ [ Test ]
132
+ public void FeatureOnHotfix_FeatureBranchDeleted ( )
133
+ {
134
+ var config = new Config
135
+ {
136
+ AssemblyVersioningScheme = AssemblyVersioningScheme . MajorMinorPatchTag ,
137
+ VersioningMode = VersioningMode . ContinuousDeployment
138
+ } ;
139
+
140
+ using ( var fixture = new EmptyRepositoryFixture ( ) )
141
+ {
142
+
143
+ var release450 = "release/4.5.0" ;
144
+ var hotfix451 = "hotfix/4.5.1" ;
145
+ var support45 = "support/4.5" ;
146
+ var tag450 = "4.5.0" ;
147
+ var featureBranch = "feature/some-bug-fix" ;
148
+
149
+ fixture . Repository . MakeACommit ( "initial" ) ;
150
+ fixture . Repository . CreateBranch ( "develop" ) ;
151
+ Commands . Checkout ( fixture . Repository , "develop" ) ;
152
+
153
+ // create release branch
154
+ fixture . Repository . CreateBranch ( release450 ) ;
155
+ Commands . Checkout ( fixture . Repository , release450 ) ;
156
+ fixture . AssertFullSemver ( config , "4.5.0-beta.0" ) ;
157
+ fixture . Repository . MakeACommit ( "blabla" ) ;
158
+ Commands . Checkout ( fixture . Repository , "develop" ) ;
159
+ fixture . Repository . MergeNoFF ( release450 , Generate . SignatureNow ( ) ) ;
160
+ Commands . Checkout ( fixture . Repository , "master" ) ;
161
+ fixture . Repository . MergeNoFF ( release450 , Generate . SignatureNow ( ) ) ;
162
+
163
+ // create support branch
164
+ fixture . Repository . CreateBranch ( support45 ) ;
165
+ Commands . Checkout ( fixture . Repository , support45 ) ;
166
+ fixture . Repository . ApplyTag ( tag450 ) ;
167
+ fixture . AssertFullSemver ( config , "4.5.0" ) ;
168
+
169
+ // create hotfix branch
170
+ fixture . Repository . CreateBranch ( hotfix451 ) ;
171
+ Commands . Checkout ( fixture . Repository , hotfix451 ) ;
172
+
173
+ // feature branch from hotfix
174
+ fixture . Repository . CreateBranch ( featureBranch ) ;
175
+ Commands . Checkout ( fixture . Repository , featureBranch ) ;
176
+ fixture . Repository . MakeACommit ( "blabla" ) ; // commit 1
177
+ Commands . Checkout ( fixture . Repository , hotfix451 ) ;
178
+ fixture . Repository . MergeNoFF ( featureBranch , Generate . SignatureNow ( ) ) ; // commit 2
179
+ fixture . Repository . Branches . Remove ( featureBranch ) ;
180
+ fixture . AssertFullSemver ( config , "4.5.1-beta.2" ) ;
181
+ }
182
+ }
183
+
184
+ /// <summary>
185
+ /// Create a feature branch from a hotfix branch, and merge back, but don't delete it
186
+ /// </summary>
187
+ [ Test ]
188
+ public void FeatureOnHotfix_FeatureBranchNotDeleted ( )
189
+ {
190
+ var config = new Config
191
+ {
192
+ AssemblyVersioningScheme = AssemblyVersioningScheme . MajorMinorPatchTag ,
193
+ VersioningMode = VersioningMode . ContinuousDeployment
194
+ } ;
195
+
196
+ using ( var fixture = new EmptyRepositoryFixture ( ) )
197
+ {
198
+
199
+ var release450 = "release/4.5.0" ;
200
+ var hotfix451 = "hotfix/4.5.1" ;
201
+ var support45 = "support/4.5" ;
202
+ var tag450 = "4.5.0" ;
203
+ var featureBranch = "feature/some-bug-fix" ;
204
+
205
+ fixture . Repository . MakeACommit ( "initial" ) ;
206
+ fixture . Repository . CreateBranch ( "develop" ) ;
207
+ Commands . Checkout ( fixture . Repository , "develop" ) ;
208
+
209
+ // create release branch
210
+ fixture . Repository . CreateBranch ( release450 ) ;
211
+ Commands . Checkout ( fixture . Repository , release450 ) ;
212
+ fixture . AssertFullSemver ( config , "4.5.0-beta.0" ) ;
213
+ fixture . Repository . MakeACommit ( "blabla" ) ;
214
+ Commands . Checkout ( fixture . Repository , "develop" ) ;
215
+ fixture . Repository . MergeNoFF ( release450 , Generate . SignatureNow ( ) ) ;
216
+ Commands . Checkout ( fixture . Repository , "master" ) ;
217
+ fixture . Repository . MergeNoFF ( release450 , Generate . SignatureNow ( ) ) ;
218
+
219
+ // create support branch
220
+ fixture . Repository . CreateBranch ( support45 ) ;
221
+ Commands . Checkout ( fixture . Repository , support45 ) ;
222
+ fixture . Repository . ApplyTag ( tag450 ) ;
223
+ fixture . AssertFullSemver ( config , "4.5.0" ) ;
224
+
225
+ // create hotfix branch
226
+ fixture . Repository . CreateBranch ( hotfix451 ) ;
227
+ Commands . Checkout ( fixture . Repository , hotfix451 ) ;
228
+
229
+ // feature branch from hotfix
230
+ fixture . Repository . CreateBranch ( featureBranch ) ;
231
+ Commands . Checkout ( fixture . Repository , featureBranch ) ;
232
+ fixture . Repository . MakeACommit ( "blabla" ) ; // commit 1
233
+ Commands . Checkout ( fixture . Repository , hotfix451 ) ;
234
+ fixture . Repository . MergeNoFF ( featureBranch , Generate . SignatureNow ( ) ) ; // commit 2
235
+ fixture . AssertFullSemver ( config , "4.5.1-beta.2" ) ;
236
+ }
237
+ }
238
+
126
239
}
0 commit comments