1
1
using System ;
2
2
using System . IO ;
3
3
using System . Linq ;
4
- using System . Text . RegularExpressions ;
5
4
using GitVersion . Common ;
6
5
using GitVersion . Configuration ;
7
6
using GitVersion . Exceptions ;
@@ -47,20 +46,6 @@ public SemanticVersion FindVersion(GitVersionContext context)
47
46
return FindVersionInternal ( context ) ;
48
47
}
49
48
50
- private static void EnsureHeadIsNotDetached ( GitVersionContext context )
51
- {
52
- if ( ! context . CurrentBranch . IsDetachedHead ( ) )
53
- {
54
- return ;
55
- }
56
-
57
- var message = string . Format (
58
- "It looks like the branch being examined is a detached Head pointing to commit '{0}'. " +
59
- "Without a proper branch name GitVersion cannot determine the build version." ,
60
- context . CurrentCommit . Id . ToString ( 7 ) ) ;
61
- throw new WarningException ( message ) ;
62
- }
63
-
64
49
public SemanticVersion FindVersionInternal ( GitVersionContext context )
65
50
{
66
51
SemanticVersion taggedSemanticVersion = null ;
@@ -129,7 +114,7 @@ private SemanticVersion PerformIncrement(GitVersionContext context, BaseVersion
129
114
130
115
private void UpdatePreReleaseTag ( GitVersionContext context , SemanticVersion semanticVersion , string branchNameOverride )
131
116
{
132
- var tagToUse = GetBranchSpecificTag ( context . Configuration , context . CurrentBranch . FriendlyName , branchNameOverride ) ;
117
+ var tagToUse = context . Configuration . GetBranchSpecificTag ( log , context . CurrentBranch . FriendlyName , branchNameOverride ) ;
133
118
134
119
int ? number = null ;
135
120
@@ -152,27 +137,18 @@ private void UpdatePreReleaseTag(GitVersionContext context, SemanticVersion sema
152
137
semanticVersion . PreReleaseTag = new SemanticVersionPreReleaseTag ( tagToUse , number ) ;
153
138
}
154
139
155
- public string GetBranchSpecificTag ( EffectiveConfiguration configuration , string branchFriendlyName , string branchNameOverride )
140
+ private static void EnsureHeadIsNotDetached ( GitVersionContext context )
156
141
{
157
- var tagToUse = configuration . Tag ;
158
- if ( tagToUse == "useBranchName" )
142
+ if ( ! context . CurrentBranch . IsDetachedHead ( ) )
159
143
{
160
- tagToUse = "{BranchName}" ;
144
+ return ;
161
145
}
162
- if ( tagToUse . Contains ( "{BranchName}" ) )
163
- {
164
- log . Info ( "Using branch name to calculate version tag" ) ;
165
-
166
- var branchName = branchNameOverride ?? branchFriendlyName ;
167
- if ( ! string . IsNullOrWhiteSpace ( configuration . BranchPrefixToTrim ) )
168
- {
169
- branchName = branchName . RegexReplace ( configuration . BranchPrefixToTrim , string . Empty , RegexOptions . IgnoreCase ) ;
170
- }
171
- branchName = branchName . RegexReplace ( "[^a-zA-Z0-9-]" , "-" ) ;
172
146
173
- tagToUse = tagToUse . Replace ( "{BranchName}" , branchName ) ;
174
- }
175
- return tagToUse ;
147
+ var message = string . Format (
148
+ "It looks like the branch being examined is a detached Head pointing to commit '{0}'. " +
149
+ "Without a proper branch name GitVersion cannot determine the build version." ,
150
+ context . CurrentCommit . Id . ToString ( 7 ) ) ;
151
+ throw new WarningException ( message ) ;
176
152
}
177
153
178
154
private static bool MajorMinorPatchEqual ( SemanticVersion lastTag , SemanticVersion baseVersion )
0 commit comments