@@ -6,7 +6,7 @@ namespace Common.Addins.GitVersion;
66/// <summary>
77/// The GitVersion runner.
88/// </summary>
9- public sealed class GitVersionRunner : Tool < GitVersionSettings >
9+ public sealed partial class GitVersionRunner : Tool < GitVersionSettings >
1010{
1111 private readonly ICakeLog _log ;
1212
@@ -38,14 +38,13 @@ public GitVersion Run(GitVersionSettings settings)
3838 Run ( settings , GetArguments ( settings ) , new ProcessSettings { RedirectStandardOutput = true } , process =>
3939 {
4040 output = string . Join ( "\n " , process . GetStandardOutput ( ) ) ;
41- if ( this . _log . Verbosity < Verbosity . Diagnostic )
41+ if ( this . _log . Verbosity >= Verbosity . Diagnostic ) return ;
42+ var regex = ParseErrorRegex ( ) ;
43+ var errors = regex . Matches ( output )
44+ . SelectMany ( match => new [ ] { match . Groups [ 1 ] . Value , match . Groups [ 2 ] . Value } ) ;
45+ foreach ( var error in errors )
4246 {
43- var errors = Regex . Matches ( output , @"( *ERROR:? [^\n]*)\n([^\n]*)" )
44- . SelectMany ( match => new [ ] { match . Groups [ 1 ] . Value , match . Groups [ 2 ] . Value } ) ;
45- foreach ( var error in errors )
46- {
47- this . _log . Error ( error ) ;
48- }
47+ this . _log . Error ( error ) ;
4948 }
5049 } ) ;
5150
@@ -68,6 +67,7 @@ private ProcessArgumentBuilder GetArguments(GitVersionSettings settings)
6867 builder . Append ( "-output" ) ;
6968 builder . Append ( "json" ) ;
7069 }
70+
7171 if ( settings . OutputTypes . Contains ( GitVersionOutput . BuildServer ) )
7272 {
7373 builder . Append ( "-output" ) ;
@@ -116,7 +116,8 @@ private ProcessArgumentBuilder GetArguments(GitVersionSettings settings)
116116 }
117117 else
118118 {
119- this . _log . Warning ( "If you leave the branch name for GitVersion unset, it will fallback to the default branch for the repository." ) ;
119+ this . _log . Warning (
120+ "If you leave the branch name for GitVersion unset, it will fallback to the default branch for the repository." ) ;
120121 }
121122
122123 if ( ! string . IsNullOrWhiteSpace ( settings . Commit ) )
@@ -150,6 +151,7 @@ private ProcessArgumentBuilder GetArguments(GitVersionSettings settings)
150151 builder . Append ( "-verbosity" ) ;
151152 builder . Append ( verbosity . ToString ( ) ) ;
152153 }
154+
153155 return builder ;
154156 }
155157
@@ -163,5 +165,14 @@ private ProcessArgumentBuilder GetArguments(GitVersionSettings settings)
163165 /// Gets the possible names of the tool executable.
164166 /// </summary>
165167 /// <returns>The tool executable name.</returns>
166- protected override IEnumerable < string > GetToolExecutableNames ( ) => new [ ] { "GitVersion.exe" , "dotnet-gitversion" , "dotnet-gitversion.exe" , "gitversion" } ;
168+ protected override IEnumerable < string > GetToolExecutableNames ( ) =>
169+ [
170+ "GitVersion.exe" ,
171+ "dotnet-gitversion" ,
172+ "dotnet-gitversion.exe" ,
173+ "gitversion"
174+ ] ;
175+
176+ [ GeneratedRegex ( @"( *ERROR:? [^\n]*)\n([^\n]*)" ) ]
177+ private static partial Regex ParseErrorRegex ( ) ;
167178}
0 commit comments