@@ -16,11 +16,13 @@ public class ArgumentParser : IArgumentParser
16
16
private readonly IEnvironment environment ;
17
17
private readonly ICurrentBuildAgent buildAgent ;
18
18
private readonly IConsole console ;
19
+ private readonly IGlobbingResolver globbingResolver ;
19
20
20
- public ArgumentParser ( IEnvironment environment , ICurrentBuildAgent buildAgent , IConsole console )
21
+ public ArgumentParser ( IEnvironment environment , ICurrentBuildAgent buildAgent , IConsole console , IGlobbingResolver globbingResolver )
21
22
{
22
23
this . environment = environment ?? throw new ArgumentNullException ( nameof ( environment ) ) ;
23
24
this . console = console ?? throw new ArgumentNullException ( nameof ( console ) ) ;
25
+ this . globbingResolver = globbingResolver ?? throw new ArgumentNullException ( nameof ( globbingResolver ) ) ;
24
26
this . buildAgent = buildAgent ;
25
27
}
26
28
@@ -87,6 +89,8 @@ public Arguments ParseArguments(string[] commandLineArguments)
87
89
? System . Environment . CurrentDirectory
88
90
: firstArgument ;
89
91
92
+ arguments . TargetPath = arguments . TargetPath . TrimEnd ( '/' , '\\ ' ) ;
93
+ arguments . UpdateAssemblyInfoFileName = ResolveFiles ( arguments . TargetPath , arguments . UpdateAssemblyInfoFileName ) . ToHashSet ( ) ;
90
94
arguments . NoFetch = arguments . NoFetch || buildAgent != null && buildAgent . PreventFetch ( ) ;
91
95
92
96
return arguments ;
@@ -234,7 +238,6 @@ private void ParseArguments(Arguments arguments, NameValueCollection switchesAnd
234
238
if ( name . IsSwitch ( "showConfig" ) )
235
239
{
236
240
ParseShowConfig ( value , arguments ) ;
237
-
238
241
return ;
239
242
}
240
243
@@ -311,6 +314,21 @@ private void ParseArguments(Arguments arguments, NameValueCollection switchesAnd
311
314
throw new WarningException ( couldNotParseMessage ) ;
312
315
}
313
316
317
+ private void AddAuthentication ( Arguments arguments )
318
+ {
319
+ var username = environment . GetEnvironmentVariable ( "GITVERSION_REMOTE_USERNAME" ) ;
320
+ if ( ! string . IsNullOrWhiteSpace ( username ) )
321
+ {
322
+ arguments . Authentication . Username = username ;
323
+ }
324
+
325
+ var password = environment . GetEnvironmentVariable ( "GITVERSION_REMOTE_PASSWORD" ) ;
326
+ if ( ! string . IsNullOrWhiteSpace ( password ) )
327
+ {
328
+ arguments . Authentication . Username = password ;
329
+ }
330
+ }
331
+
314
332
private static void ParseShowConfig ( string value , Arguments arguments )
315
333
{
316
334
if ( value . IsTrue ( ) )
@@ -456,18 +474,18 @@ private static void ParseUpdateAssemblyInfo(Arguments arguments, string value, s
456
474
}
457
475
}
458
476
459
- private void AddAuthentication ( Arguments arguments )
477
+ private IEnumerable < string > ResolveFiles ( string workingDirectory , ISet < string > assemblyInfoFiles )
460
478
{
461
- var username = environment . GetEnvironmentVariable ( "GITVERSION_REMOTE_USERNAME" ) ;
462
- if ( ! string . IsNullOrWhiteSpace ( username ) )
463
- {
464
- arguments . Authentication . Username = username ;
465
- }
479
+ if ( assemblyInfoFiles == null ) yield break ;
466
480
467
- var password = environment . GetEnvironmentVariable ( "GITVERSION_REMOTE_PASSWORD" ) ;
468
- if ( ! string . IsNullOrWhiteSpace ( password ) )
481
+ foreach ( var file in assemblyInfoFiles )
469
482
{
470
- arguments . Authentication . Username = password ;
483
+ var paths = globbingResolver . Resolve ( workingDirectory , file ) ;
484
+
485
+ foreach ( var path in paths )
486
+ {
487
+ yield return Path . GetFullPath ( Path . Combine ( workingDirectory , path ) ) ;
488
+ }
471
489
}
472
490
}
473
491
0 commit comments