File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed
GitVersionCore.Tests/IntegrationTests/GitHubFlow Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -136,4 +136,30 @@ public void GivenARepositoryWithTagAndOldNextVersionTxtFileAndNoCommits_VersionS
136136 fixture . AssertFullSemver ( "1.1.0+0" ) ;
137137 }
138138 }
139+
140+ [ Test ]
141+ public void CanSpecifyTagPrefixes ( )
142+ {
143+ using ( var fixture = new EmptyRepositoryFixture ( new Config { TagPrefix = "version-" } ) )
144+ {
145+ const string TaggedVersion = "version-1.0.3" ;
146+ fixture . Repository . MakeATaggedCommit ( TaggedVersion ) ;
147+ fixture . Repository . MakeCommits ( 5 ) ;
148+
149+ fixture . AssertFullSemver ( "1.0.4+5" ) ;
150+ }
151+ }
152+
153+ [ Test ]
154+ public void CanSpecifyTagPrefixesAsRegex ( )
155+ {
156+ using ( var fixture = new EmptyRepositoryFixture ( new Config { TagPrefix = "[version-|v]" } ) )
157+ {
158+ const string TaggedVersion = "v1.0.3" ;
159+ fixture . Repository . MakeATaggedCommit ( TaggedVersion ) ;
160+ fixture . Repository . MakeCommits ( 5 ) ;
161+
162+ fixture . AssertFullSemver ( "1.0.4+5" ) ;
163+ }
164+ }
139165}
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ public Config()
99 AssemblyVersioningScheme = AssemblyVersioningScheme . MajorMinorPatch ;
1010 DevelopBranchTag = "unstable" ;
1111 ReleaseBranchTag = "beta" ;
12+ TagPrefix = "v" ;
1213 }
1314
1415 public AssemblyVersioningScheme AssemblyVersioningScheme { get ; set ; }
@@ -18,5 +19,8 @@ public Config()
1819
1920 [ YamlAlias ( "release-branch-tag" ) ]
2021 public string ReleaseBranchTag { get ; set ; }
22+
23+ [ YamlAlias ( "tag-prefix" ) ]
24+ public string TagPrefix { get ; set ; }
2125 }
2226}
Original file line number Diff line number Diff line change 11namespace GitVersion
22{
33 using System . Linq ;
4+ using System . Text . RegularExpressions ;
45 using LibGit2Sharp ;
56
67 public class LastTaggedReleaseFinder
@@ -16,8 +17,9 @@ public bool GetVersion(out VersionTaggedCommit versionTaggedCommit)
1617 {
1718 var tags = context . Repository . Tags . Select ( t =>
1819 {
20+ var match = Regex . Match ( t . Name , string . Format ( "({0})?(?<version>.*)" , context . Configuration . TagPrefix ) ) ;
1921 SemanticVersion version ;
20- if ( SemanticVersion . TryParse ( t . Name . TrimStart ( 'v' ) , out version ) )
22+ if ( SemanticVersion . TryParse ( match . Groups [ "version" ] . Value , out version ) )
2123 {
2224 return new VersionTaggedCommit ( ( Commit ) t . Target , version ) ;
2325 }
You can’t perform that action at this time.
0 commit comments