File tree 3 files changed +34
-1
lines changed
GitVersionCore.Tests/IntegrationTests/GitHubFlow
3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -136,4 +136,30 @@ public void GivenARepositoryWithTagAndOldNextVersionTxtFileAndNoCommits_VersionS
136
136
fixture . AssertFullSemver ( "1.1.0+0" ) ;
137
137
}
138
138
}
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
+ }
139
165
}
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ public Config()
9
9
AssemblyVersioningScheme = AssemblyVersioningScheme . MajorMinorPatch ;
10
10
DevelopBranchTag = "unstable" ;
11
11
ReleaseBranchTag = "beta" ;
12
+ TagPrefix = "v" ;
12
13
}
13
14
14
15
public AssemblyVersioningScheme AssemblyVersioningScheme { get ; set ; }
@@ -18,5 +19,8 @@ public Config()
18
19
19
20
[ YamlAlias ( "release-branch-tag" ) ]
20
21
public string ReleaseBranchTag { get ; set ; }
22
+
23
+ [ YamlAlias ( "tag-prefix" ) ]
24
+ public string TagPrefix { get ; set ; }
21
25
}
22
26
}
Original file line number Diff line number Diff line change 1
1
namespace GitVersion
2
2
{
3
+ using System ;
3
4
using System . Linq ;
5
+ using System . Text . RegularExpressions ;
4
6
using LibGit2Sharp ;
5
7
6
8
public class LastTaggedReleaseFinder
@@ -16,8 +18,9 @@ public bool GetVersion(out VersionTaggedCommit versionTaggedCommit)
16
18
{
17
19
var tags = context . Repository . Tags . Select ( t =>
18
20
{
21
+ var match = Regex . Match ( t . Name , string . Format ( "({0})?(?<version>.*)" , context . Configuration . TagPrefix ) ) ;
19
22
SemanticVersion version ;
20
- if ( SemanticVersion . TryParse ( t . Name . TrimStart ( 'v' ) , out version ) )
23
+ if ( SemanticVersion . TryParse ( match . Groups [ "version" ] . Value , out version ) )
21
24
{
22
25
return new VersionTaggedCommit ( ( Commit ) t . Target , version ) ;
23
26
}
You can’t perform that action at this time.
0 commit comments