@@ -339,6 +339,104 @@ public void MergingFeatureBranchThatIncrementsMinorNumberIncrementsMinorVersionO
339
339
fixture . AssertFullSemver ( currentConfig , "1.1.0" ) ;
340
340
}
341
341
}
342
+
343
+ [ Test ]
344
+ public void VerifyIncrementConfigIsHonoured ( )
345
+ {
346
+ var minorIncrementConfig = new Config
347
+ {
348
+ VersioningMode = VersioningMode . Mainline ,
349
+ Increment = IncrementStrategy . Minor ,
350
+ Branches = new Dictionary < string , BranchConfig >
351
+ {
352
+ {
353
+ "master" ,
354
+ new BranchConfig
355
+ {
356
+ Increment = IncrementStrategy . Minor ,
357
+ Name = "master" ,
358
+ Regex = "master"
359
+ }
360
+ } ,
361
+ {
362
+ "feature" ,
363
+ new BranchConfig
364
+ {
365
+ Increment = IncrementStrategy . Minor ,
366
+ Name = "feature" ,
367
+ Regex = "features?[/-]"
368
+ }
369
+ }
370
+ }
371
+ } ;
372
+
373
+ using ( var fixture = new EmptyRepositoryFixture ( ) )
374
+ {
375
+ fixture . Repository . MakeACommit ( "1" ) ;
376
+ fixture . MakeATaggedCommit ( "1.0.0" ) ;
377
+
378
+ fixture . BranchTo ( "feature/foo" , "foo" ) ;
379
+ fixture . MakeACommit ( "2" ) ;
380
+ fixture . AssertFullSemver ( minorIncrementConfig , "1.1.0-foo.1" ) ;
381
+ fixture . MakeACommit ( "2.1" ) ;
382
+ fixture . AssertFullSemver ( minorIncrementConfig , "1.1.0-foo.2" ) ;
383
+ fixture . Checkout ( "master" ) ;
384
+ fixture . MergeNoFF ( "feature/foo" ) ;
385
+
386
+ fixture . AssertFullSemver ( minorIncrementConfig , "1.1.0" ) ;
387
+
388
+ fixture . BranchTo ( "feature/foo2" , "foo2" ) ;
389
+ fixture . MakeACommit ( "3 +semver: patch" ) ;
390
+ fixture . AssertFullSemver ( minorIncrementConfig , "1.1.1-foo2.1" ) ;
391
+ fixture . Checkout ( "master" ) ;
392
+ fixture . MergeNoFF ( "feature/foo2" ) ;
393
+ fixture . AssertFullSemver ( minorIncrementConfig , "1.1.1" ) ;
394
+
395
+ fixture . BranchTo ( "feature/foo3" , "foo3" ) ;
396
+ fixture . MakeACommit ( "4" ) ;
397
+ fixture . Checkout ( "master" ) ;
398
+ fixture . MergeNoFF ( "feature/foo3" ) ;
399
+ fixture . SequenceDiagram . NoteOver ( "Merge message contains '+semver: patch'" , "master" ) ;
400
+ var commit = fixture . Repository . Head . Tip ;
401
+ // Put semver increment in merge message
402
+ fixture . Repository . Commit ( commit . Message + " +semver: patch" , commit . Author , commit . Committer , new CommitOptions
403
+ {
404
+ AmendPreviousCommit = true
405
+ } ) ;
406
+ fixture . AssertFullSemver ( minorIncrementConfig , "1.1.2" ) ;
407
+
408
+ fixture . BranchTo ( "feature/foo4" , "foo4" ) ;
409
+ fixture . MakeACommit ( "5 +semver: major" ) ;
410
+ fixture . AssertFullSemver ( minorIncrementConfig , "2.0.0-foo4.1" ) ;
411
+ fixture . Checkout ( "master" ) ;
412
+ fixture . MergeNoFF ( "feature/foo4" ) ;
413
+ fixture . AssertFullSemver ( config , "2.0.0" ) ;
414
+
415
+ // We should evaluate any commits not included in merge commit calculations for direct commit/push or squash to merge commits
416
+ fixture . MakeACommit ( "6 +semver: major" ) ;
417
+ fixture . AssertFullSemver ( minorIncrementConfig , "3.0.0" ) ;
418
+ fixture . MakeACommit ( "7" ) ;
419
+ fixture . AssertFullSemver ( minorIncrementConfig , "3.1.0" ) ;
420
+ fixture . MakeACommit ( "8 +semver: patch" ) ;
421
+ fixture . AssertFullSemver ( minorIncrementConfig , "3.1.1" ) ;
422
+
423
+ // Finally verify that the merge commits still function properly
424
+ fixture . BranchTo ( "feature/foo5" , "foo5" ) ;
425
+ fixture . MakeACommit ( "9 +semver: patch" ) ;
426
+ fixture . AssertFullSemver ( minorIncrementConfig , "3.1.2-foo5.1" ) ;
427
+ fixture . Checkout ( "master" ) ;
428
+ fixture . MergeNoFF ( "feature/foo5" ) ;
429
+ fixture . AssertFullSemver ( minorIncrementConfig , "3.1.2" ) ;
430
+
431
+ // One more direct commit for good measure
432
+ fixture . MakeACommit ( "10 +semver: patch" ) ;
433
+ fixture . AssertFullSemver ( minorIncrementConfig , "3.1.3" ) ;
434
+ // And we can commit without bumping semver
435
+ fixture . MakeACommit ( "11 +semver: none" ) ;
436
+ fixture . AssertFullSemver ( minorIncrementConfig , "3.1.3" ) ;
437
+ Console . WriteLine ( fixture . SequenceDiagram . GetDiagram ( ) ) ;
438
+ }
439
+ }
342
440
}
343
441
344
442
static class CommitExtensions
0 commit comments