Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/GitVersionExe.Tests/ExecCmdLineArgumentTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using GitTools;
using GitTools.Testing;
using GitVersion;
using NUnit.Framework;
Expand Down Expand Up @@ -66,4 +69,25 @@ public void WorkingDirectoryWithoutGitFolderCrashesWithInformativeMessage()
var results = GitVersionHelper.ExecuteIn(Environment.SystemDirectory, null, isTeamCity: false, logToFile: false);
results.Output.ShouldContain("Can't find the .git directory in");
}

[Test]
[Category("NoMono")]
[Description("Doesn't work on Mono/Unix because of the path heuristics that needs to be done there in order to figure out whether the first argument actually is a path.")]
public void WorkingDirectoryDoesNotExistCrashesWithInformativeMessage()
{
var workingDirectory = Path.Combine(Environment.CurrentDirectory, Guid.NewGuid().ToString("N"));
var gitVersion = Path.Combine(PathHelper.GetCurrentDirectory(), "GitVersion.exe");
var output = new StringBuilder();
var exitCode = ProcessHelper.Run(
s => output.AppendLine(s),
s => output.AppendLine(s),
null,
gitVersion,
workingDirectory,
Environment.CurrentDirectory);

exitCode.ShouldNotBe(0);
var outputString = output.ToString();
outputString.ShouldContain(string.Format("The working directory '{0}' does not exist.", workingDirectory), () => outputString);
}
}
24 changes: 20 additions & 4 deletions src/GitVersionExe/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ static int VerifyArgumentsAndRun()
}

ConfigureLogging(arguments);

if (!Directory.Exists(arguments.TargetPath))
{
Logger.WriteWarning(string.Format("The working directory '{0}' does not exist.", arguments.TargetPath));
}
else
{
Logger.WriteInfo("Working directory: " + arguments.TargetPath);
}

if (arguments.Init)
{
ConfigurationProvider.Init(arguments.TargetPath, fileSystem, new ConsoleAdapter());
Expand All @@ -80,8 +90,6 @@ static int VerifyArgumentsAndRun()
arguments.Output = OutputType.BuildServer;
}

Logger.WriteInfo("Working directory: " + arguments.TargetPath);

SpecifiedArgumentRunner.Run(arguments, fileSystem);
}
catch (WarningException exception)
Expand All @@ -98,9 +106,17 @@ static int VerifyArgumentsAndRun()
if (arguments != null)
{
Logger.WriteInfo(string.Empty);
Logger.WriteInfo("Here is the current git graph (please include in issue): ");
Logger.WriteInfo("Attempting to show the current git graph (please include in issue): ");
Logger.WriteInfo("Showing max of 100 commits");
GitTools.LibGitExtensions.DumpGraph(arguments.TargetPath, Logger.WriteInfo, 100);

try
{
GitTools.LibGitExtensions.DumpGraph(arguments.TargetPath, Logger.WriteInfo, 100);
}
catch (Exception dumpGraphException)
{
Logger.WriteError("Couldn't dump the git graph due to the following error: " + dumpGraphException);
}
}
return 1;
}
Expand Down