Skip to content

Commit f0dbaf0

Browse files
committed
Try/Catch 'git log' in DumpGraph() so tests don't fail if git isn't installed and available in PATH.
1 parent 91297fd commit f0dbaf0

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

GitVersionCore.Tests/Helpers/GitTestExtensions.cs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,24 @@ public static void DumpGraph(this IRepository repository)
1515
{
1616
var output = new StringBuilder();
1717

18-
ProcessHelper.Run(
19-
o => output.AppendLine(o),
20-
e => output.AppendLineFormat("ERROR: {0}", e),
21-
null,
22-
"git",
23-
@"log --graph --abbrev-commit --decorate --date=relative --all",
24-
repository.Info.Path);
18+
try
19+
{
20+
ProcessHelper.Run(
21+
o => output.AppendLine(o),
22+
e => output.AppendLineFormat("ERROR: {0}", e),
23+
null,
24+
"git",
25+
@"log --graph --abbrev-commit --decorate --date=relative --all",
26+
repository.Info.Path);
27+
}
28+
catch (FileNotFoundException exception)
29+
{
30+
if (exception.FileName != "git")
31+
throw;
32+
33+
output.AppendLine("Could not execute 'git log' due to the following error:");
34+
output.AppendLine(exception.ToString());
35+
}
2536

2637
Trace.Write(output.ToString());
2738
}

0 commit comments

Comments
 (0)