Skip to content

Commit 24cf318

Browse files
authored
Merge pull request #4762 from davidjenni/fix-diag-switch
Fix diag switch
2 parents 352934c + 0b54846 commit 24cf318

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

src/GitVersion.App.Tests/ArgumentParserTests.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,21 @@ public void AllowshallowTrueWhenDefined()
636636
arguments.AllowShallow.ShouldBe(true);
637637
}
638638

639+
[Test]
640+
public void DiagTrueWhenDefined()
641+
{
642+
var arguments = this.argumentParser.ParseArguments("-diag");
643+
arguments.Diag.ShouldBe(true);
644+
}
645+
646+
[Test]
647+
public void DiagAndLogToConsoleIsNotIgnored()
648+
{
649+
var arguments = this.argumentParser.ParseArguments("-diag -l console");
650+
arguments.Diag.ShouldBe(true);
651+
arguments.LogFilePath.ShouldBe("console");
652+
}
653+
639654
[Test]
640655
public void OtherArgumentsCanBeParsedBeforeNofetch()
641656
{

src/GitVersion.App/ArgumentParser.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,7 @@ private static bool ParseSwitches(Arguments arguments, string? name, IReadOnlyLi
212212

213213
if (name.IsSwitch("diag"))
214214
{
215-
if (value?.IsTrue() != false)
216-
{
217-
arguments.Diag = true;
218-
}
219-
215+
arguments.Diag = true;
220216
return true;
221217
}
222218

src/GitVersion.App/ArgumentParserExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public bool IsSwitch(string switchName)
7373

7474
public bool ArgumentRequiresValue(int argumentIndex)
7575
{
76-
var booleanArguments = new[] { "updateassemblyinfo", "ensureassemblyinfo", "nofetch", "nonormalize", "nocache", "allowshallow" };
76+
var booleanArguments = new[] { "updateassemblyinfo", "ensureassemblyinfo", "nofetch", "nonormalize", "nocache", "allowshallow", "diag" };
7777

7878
var argumentMightRequireValue = !booleanArguments.Contains(singleArgument[1..], StringComparer.OrdinalIgnoreCase);
7979

0 commit comments

Comments
 (0)