Skip to content

Commit 5d2b42f

Browse files
Inokarturcic
authored andcommitted
#2089 fix parsing of command line switch arguments
1 parent 4961b47 commit 5d2b42f

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

src/GitVersionCore/Extensions/StringExtensions.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ public static bool ArgumentRequiresValue(this string argument, int argumentIndex
105105
"init",
106106
"updateassemblyinfo",
107107
"ensureassemblyinfo",
108-
"nofetch"
108+
"nofetch",
109+
"nonormalize",
110+
"nocache",
109111
};
110112

111113
var argumentMightRequireValue = !booleanArguments.Contains(argument.Substring(1), StringComparer.OrdinalIgnoreCase);

src/GitVersionExe.Tests/ArgumentParserTests.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,22 @@ public void OtherArgumentsCanBeParsedBeforeNofetch()
327327
arguments.NoFetch.ShouldBe(true);
328328
}
329329

330+
[Test]
331+
public void OtherArgumentsCanBeParsedBeforeNonormalize()
332+
{
333+
var arguments = argumentParser.ParseArguments("targetpath -nonormalize");
334+
arguments.TargetPath.ShouldBe("targetpath");
335+
arguments.NoNormalize.ShouldBe(true);
336+
}
337+
338+
[Test]
339+
public void OtherArgumentsCanBeParsedBeforeNocache()
340+
{
341+
var arguments = argumentParser.ParseArguments("targetpath -nocache");
342+
arguments.TargetPath.ShouldBe("targetpath");
343+
arguments.NoCache.ShouldBe(true);
344+
}
345+
330346
[Test]
331347
public void OtherArgumentsCanBeParsedAfterNofetch()
332348
{
@@ -335,6 +351,36 @@ public void OtherArgumentsCanBeParsedAfterNofetch()
335351
arguments.Proj.ShouldBe("foo.sln");
336352
}
337353

354+
[Test]
355+
public void OtherArgumentsCanBeParsedAfterNonormalize()
356+
{
357+
var arguments = argumentParser.ParseArguments("-nonormalize -proj foo.sln");
358+
arguments.NoNormalize.ShouldBe(true);
359+
arguments.Proj.ShouldBe("foo.sln");
360+
}
361+
362+
[Test]
363+
public void OtherArgumentsCanBeParsedAfterNocache()
364+
{
365+
var arguments = argumentParser.ParseArguments("-nocache -proj foo.sln");
366+
arguments.NoCache.ShouldBe(true);
367+
arguments.Proj.ShouldBe("foo.sln");
368+
}
369+
370+
[TestCase("-nofetch -nonormalize -nocache")]
371+
[TestCase("-nofetch -nocache -nonormalize")]
372+
[TestCase("-nocache -nofetch -nonormalize")]
373+
[TestCase("-nocache -nonormalize -nofetch")]
374+
[TestCase("-nonormalize -nocache -nofetch")]
375+
[TestCase("-nonormalize -nofetch -nocache")]
376+
public void SeveralSwitchesCanBeParsed(string commandLineArgs)
377+
{
378+
var arguments = argumentParser.ParseArguments(commandLineArgs);
379+
arguments.NoCache.ShouldBe(true);
380+
arguments.NoNormalize.ShouldBe(true);
381+
arguments.NoFetch.ShouldBe(true);
382+
}
383+
338384
[Test]
339385
public void LogPathCanContainForwardSlash()
340386
{

0 commit comments

Comments
 (0)