Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 7a75448

Browse files
committed
Show friendly error message if Git.exe not on PATH
VS 2017 will guide user to install Git for Windows as soon as Team Explorer is opened. The user not having Git.exe on their PATH isn't the common case, so don't want to overengineer a solution.
1 parent e61e110 commit 7a75448

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/GitHub.App/Services/PullRequestService.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,28 @@ public IObservable<Unit> SyncSubmodules(ILocalRepositoryModel repository)
198198
var exitCode = await SyncSubmodules(repository.LocalPath, line => output.WriteLine(line));
199199
if (exitCode != 0)
200200
{
201-
var ex = new ApplicationException(output.ToString());
201+
// Replace with friendly message if Git.exe isn't on path.
202+
// If culture isn't English, user will see the local equivalent of:
203+
// "'git' is not recognized as an internal or external command"
204+
var message = output.ToString();
205+
if (exitCode == 1 && message.StartsWith("'git' is not recognized as an internal or external command,", StringComparison.Ordinal))
206+
{
207+
message =
208+
@"Couldn't find Git.exe on PATH.
209+
210+
Please install Git for Windows from:
211+
https://git-scm.com/download/win";
212+
}
213+
214+
var ex = new ApplicationException(message);
202215
return Observable.Throw<Unit>(ex);
203216
}
204217

205218
return Observable.Return(Unit.Default);
206219
});
207220
}
208221

209-
// HACK: This is just a prototype!
222+
// LibGit2Sharp has limited submodule support so shelling out Git.exe for submodule commands.
210223
async Task<int> SyncSubmodules(string workingDir, Action<string> progress = null)
211224
{
212225
var cmdArguments = "/C git submodule init && git submodule sync --recursive && git submodule update --recursive";

0 commit comments

Comments
 (0)