@@ -48,6 +48,50 @@ public void CanUseCommitMessagesToBumpVersion()
48
48
fixture . AssertFullSemver ( "2.0.0+2" ) ;
49
49
}
50
50
51
+ [ Test ]
52
+ public void CanUseConventionalCommitsToBumpVersion ( )
53
+ {
54
+ var configuration = new Config
55
+ {
56
+ VersioningMode = GitVersion . VersionCalculation . VersioningMode . Mainline ,
57
+
58
+ // For future debugging of this regex: https://regex101.com/r/UfzIwS/1
59
+ MajorVersionBumpMessage = "(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\\ ([\\ w\\ s]*\\ ))?(!:|:.*\\ n\\ n.*\\ n\\ n.*BREAKING.*).*" ,
60
+
61
+ // For future debugging of this regex: https://regex101.com/r/9ccNam/1
62
+ MinorVersionBumpMessage = "(feat)(\\ ([\\ w\\ s]*\\ ))?:" ,
63
+
64
+ // For future debugging of this regex: https://regex101.com/r/ALKccf/1
65
+ PatchVersionBumpMessage = "(build|chore|ci|docs|fix|perf|refactor|revert|style|test)(\\ ([\\ w\\ s]*\\ ))?:(.*\\ n\\ n.*\\ n\\ n.*BREAKING.*){0}"
66
+ } ;
67
+ using var fixture = new EmptyRepositoryFixture ( ) ;
68
+ fixture . Repository . MakeACommit ( ) ;
69
+ fixture . MakeATaggedCommit ( "1.0.0" ) ;
70
+
71
+ fixture . Repository . MakeACommit ( "feat(Api): Added some new endpoints" ) ;
72
+ fixture . AssertFullSemver ( "1.1.0" , configuration ) ;
73
+
74
+ // This tests if adding an exclamation mark after the type (breaking change) bumps the major version
75
+ fixture . Repository . MakeACommit ( "feat(Api)!: Changed existing API models" ) ;
76
+ fixture . AssertFullSemver ( "2.0.0" , configuration ) ;
77
+
78
+ // This tests if writing BREAKING CHANGE in the footer bumps the major version
79
+ fixture . Repository . MakeACommit ( "feat: Changed existing API models\n \n Some more descriptive text\n \n BREAKING CHANGE" ) ;
80
+ fixture . AssertFullSemver ( "3.0.0" , configuration ) ;
81
+
82
+ fixture . Repository . MakeACommit ( "chore: Cleaned up various things" ) ;
83
+ fixture . AssertFullSemver ( "3.0.1" , configuration ) ;
84
+
85
+ fixture . Repository . MakeACommit ( "chore: Cleaned up more various things" ) ;
86
+ fixture . AssertFullSemver ( "3.0.2" , configuration ) ;
87
+
88
+ fixture . Repository . MakeACommit ( "feat: Added some new functionality" ) ;
89
+ fixture . AssertFullSemver ( "3.1.0" , configuration ) ;
90
+
91
+ fixture . Repository . MakeACommit ( "feat: Added even more new functionality" ) ;
92
+ fixture . AssertFullSemver ( "3.2.0" , configuration ) ;
93
+ }
94
+
51
95
[ Test ]
52
96
public void CanUseCommitMessagesToBumpVersionBaseVersionTagIsAppliedToSameCommit ( )
53
97
{
0 commit comments