@@ -191,23 +191,18 @@ public IObservable<Unit> SyncSubmodules(ILocalRepositoryModel repository)
191191 {
192192 return Observable . Defer ( async ( ) =>
193193 {
194+ var exitCode = Where ( "git" ) ;
195+ if ( exitCode != 0 )
196+ {
197+ var ex = new ApplicationException ( App . Resources . CouldntFindGitOnPath ) ;
198+ return Observable . Throw < Unit > ( ex ) ;
199+ }
200+
194201 var output = new StringWriter ( CultureInfo . InvariantCulture ) ;
195- var exitCode = await SyncSubmodules ( repository . LocalPath , line => output . WriteLine ( line ) ) ;
202+ exitCode = await SyncSubmodules ( repository . LocalPath , line => output . WriteLine ( line ) ) ;
196203 if ( exitCode != 0 )
197204 {
198- // Replace with friendly message if Git.exe isn't on path.
199- // If culture isn't English, user will see the local equivalent of:
200- // "'git' is not recognized as an internal or external command"
201205 var message = output . ToString ( ) ;
202- if ( exitCode == 1 && message . StartsWith ( "'git' is not recognized as an internal or external command," , StringComparison . Ordinal ) )
203- {
204- message =
205- @"Couldn't find Git.exe on PATH.
206-
207- Please install Git for Windows from:
208- https://git-scm.com/download/win" ;
209- }
210-
211206 var ex = new ApplicationException ( message ) ;
212207 return Observable . Throw < Unit > ( ex ) ;
213208 }
@@ -239,6 +234,22 @@ await Task.WhenAll(
239234 }
240235 }
241236
237+ static int Where ( string fileName )
238+ {
239+ var cmdArguments = "/C WHERE /Q " + fileName ;
240+ var startInfo = new ProcessStartInfo ( "cmd" , cmdArguments )
241+ {
242+ UseShellExecute = false ,
243+ CreateNoWindow = true
244+ } ;
245+
246+ using ( var process = Process . Start ( startInfo ) )
247+ {
248+ process . WaitForExit ( ) ;
249+ return process . ExitCode ;
250+ }
251+ }
252+
242253 static async Task ReadLinesAsync ( TextReader reader , Action < string > progress )
243254 {
244255 string line ;
0 commit comments