diff --git a/src/GitVersion.App.Tests/ArgumentParserTests.cs b/src/GitVersion.App.Tests/ArgumentParserTests.cs index 42e7c36304..911c1f0812 100644 --- a/src/GitVersion.App.Tests/ArgumentParserTests.cs +++ b/src/GitVersion.App.Tests/ArgumentParserTests.cs @@ -636,6 +636,21 @@ public void AllowshallowTrueWhenDefined() arguments.AllowShallow.ShouldBe(true); } + [Test] + public void DiagTrueWhenDefined() + { + var arguments = this.argumentParser.ParseArguments("-diag"); + arguments.Diag.ShouldBe(true); + } + + [Test] + public void DiagAndLogToConsoleIsNotIgnored() + { + var arguments = this.argumentParser.ParseArguments("-diag -l console"); + arguments.Diag.ShouldBe(true); + arguments.LogFilePath.ShouldBe("console"); + } + [Test] public void OtherArgumentsCanBeParsedBeforeNofetch() { diff --git a/src/GitVersion.App/ArgumentParser.cs b/src/GitVersion.App/ArgumentParser.cs index 1f85a1b3d2..d7b4df31bc 100644 --- a/src/GitVersion.App/ArgumentParser.cs +++ b/src/GitVersion.App/ArgumentParser.cs @@ -212,11 +212,7 @@ private static bool ParseSwitches(Arguments arguments, string? name, IReadOnlyLi if (name.IsSwitch("diag")) { - if (value?.IsTrue() != false) - { - arguments.Diag = true; - } - + arguments.Diag = true; return true; } diff --git a/src/GitVersion.App/ArgumentParserExtensions.cs b/src/GitVersion.App/ArgumentParserExtensions.cs index 7d0dade040..286849c44b 100644 --- a/src/GitVersion.App/ArgumentParserExtensions.cs +++ b/src/GitVersion.App/ArgumentParserExtensions.cs @@ -73,7 +73,7 @@ public bool IsSwitch(string switchName) public bool ArgumentRequiresValue(int argumentIndex) { - var booleanArguments = new[] { "updateassemblyinfo", "ensureassemblyinfo", "nofetch", "nonormalize", "nocache", "allowshallow" }; + var booleanArguments = new[] { "updateassemblyinfo", "ensureassemblyinfo", "nofetch", "nonormalize", "nocache", "allowshallow", "diag" }; var argumentMightRequireValue = !booleanArguments.Contains(singleArgument[1..], StringComparer.OrdinalIgnoreCase);