Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CheckGitVersion: improve error messages #403

Merged
merged 1 commit into from
Jul 14, 2020
Merged
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
14 changes: 10 additions & 4 deletions Scalar/CommandLine/ScalarVerb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -492,24 +492,30 @@ private string GetAlternatesPath(ScalarEnlistment enlistment)
private void CheckGitVersion(ITracer tracer, ScalarEnlistment enlistment, out string version)
{
GitVersion gitVersion = null;
if (string.IsNullOrEmpty(enlistment.GitBinPath) || !GitProcess.TryGetVersion(enlistment.GitBinPath, out gitVersion, out string _))
if (string.IsNullOrEmpty(enlistment.GitBinPath))
{
this.ReportErrorAndExit(tracer, "Error: Unable to retrieve the git version");
this.ReportErrorAndExit(tracer, "Unable to find Git version on PATH");
}

if (!GitProcess.TryGetVersion(enlistment.GitBinPath, out gitVersion, out string error))
{
this.ReportErrorAndExit(tracer, $"Unable to parse Git version at '{enlistment.GitBinPath}':\n{error}");
}

version = gitVersion.ToString();
derrickstolee marked this conversation as resolved.
Show resolved Hide resolved

if (gitVersion.Platform != ScalarConstants.SupportedGitVersion.Platform)
{
this.ReportErrorAndExit(tracer, "Error: Invalid version of git {0}. Must use scalar version.", version);
this.ReportErrorAndExit(tracer, "Error: Invalid version of git {0} at {1}. Must use scalar version.", version, enlistment.GitBinPath);
}

if (gitVersion.IsLessThan(ScalarConstants.SupportedGitVersion))
{
this.ReportErrorAndExit(
tracer,
"Error: Installed git version {0} is less than the supported version of {1}.",
"Error: Installed git version {0} at {1} is less than the supported version of {2}.",
gitVersion,
enlistment.GitBinPath,
ScalarConstants.SupportedGitVersion);
}
}
Expand Down