@@ -29,6 +29,8 @@ public GitInstaller(IEnvironment environment, IProcessManager processManager,
2929
3030 public GitInstallationState SetupGitIfNeeded ( GitInstallationState state = null )
3131 {
32+ var skipSystemProbing = state != null ;
33+
3234 state = VerifyGitSettings ( state ) ;
3335 if ( state . GitIsValid && state . GitLfsIsValid )
3436 {
@@ -37,9 +39,12 @@ public GitInstallationState SetupGitIfNeeded(GitInstallationState state = null)
3739 return state ;
3840 }
3941
40- if ( environment . IsMac )
41- state = FindSystemGit ( state ) ;
42- state = SetDefaultPaths ( state ) ;
42+ if ( ! skipSystemProbing )
43+ {
44+ if ( environment . IsMac )
45+ state = FindSystemGit ( state ) ;
46+ state = SetDefaultPaths ( state ) ;
47+ }
4348
4449 state = CheckForUpdates ( state ) ;
4550
@@ -111,7 +116,7 @@ public GitInstallationState FindSystemGit(GitInstallationState state)
111116
112117 public GitInstallationState SetDefaultPaths ( GitInstallationState state )
113118 {
114- if ( ! state . GitIsValid )
119+ if ( ! state . GitIsValid && environment . IsWindows )
115120 {
116121 state . GitInstallationPath = installDetails . GitInstallationPath ;
117122 state . GitExecutablePath = installDetails . GitExecutablePath ;
@@ -292,10 +297,10 @@ private GitInstallationState ExtractGit(GitInstallationState state)
292297 } ) ;
293298 unzipTask . Progress ( p => ( ( Progress ) Progress ) ? . UpdateProgress ( 60 + ( long ) ( 20 * p . Percentage ) , 100 , unzipTask . Name ) ) ;
294299 var path = unzipTask . RunWithReturn ( true ) ;
295- var target = state . GitLfsExecutablePath ;
300+ var target = state . GitLfsInstallationPath ;
296301 if ( unzipTask . Successful )
297302 {
298- var source = path . Combine ( installDetails . GitLfsExecutable ) ;
303+ var source = path ;
299304 target . DeleteIfExists ( ) ;
300305 target . EnsureParentDirectoryExists ( ) ;
301306 source . Move ( target ) ;
@@ -335,8 +340,8 @@ public class GitInstallDetails
335340 private const string packageFeed = "http://github-vs.s3.amazonaws.com/unity/git/" ;
336341#endif
337342
338- private const string PackageVersion = "f02737a78695063deace08e96d5042710d3e32db " ;
339- private const string PackageName = "PortableGit " ;
343+ public const string GitDirectory = "git " ;
344+ public const string GitLfsDirectory = "git-lfs " ;
340345
341346 private const string gitZip = "git.zip" ;
342347 private const string gitLfsZip = "git-lfs.zip" ;
@@ -352,46 +357,33 @@ public GitInstallDetails(NPath baseDataPath, bool onWindows)
352357 GitZipPath = ZipPath . Combine ( gitZip ) ;
353358 GitLfsZipPath = ZipPath . Combine ( gitLfsZip ) ;
354359
355- var gitInstallPath = baseDataPath . Combine ( PackageNameWithVersion ) ;
356- GitInstallationPath = gitInstallPath ;
360+ GitInstallationPath = baseDataPath . Combine ( GitDirectory ) ;
361+ GitExecutablePath = GitInstallationPath . Combine ( onWindows ? "cmd" : "bin" , "git" + DefaultEnvironment . ExecutableExt ) ;
362+
363+ GitLfsInstallationPath = baseDataPath . Combine ( GitLfsDirectory ) ;
364+ GitLfsExecutablePath = GitLfsInstallationPath . Combine ( "git-lfs" + DefaultEnvironment . ExecutableExt ) ;
357365
358366 if ( onWindows )
359367 {
360- GitExecutable += "git.exe" ;
361- GitLfsExecutable += "git-lfs.exe" ;
362- GitExecutablePath = gitInstallPath . Combine ( "cmd" , GitExecutable ) ;
363368 GitPackageFeed = packageFeed + $ "windows/{ GitPackageName } ";
364369 GitLfsPackageFeed = packageFeed + $ "windows/{ GitLfsPackageName } ";
365370 }
366371 else
367372 {
368- GitExecutable = "git" ;
369- GitLfsExecutable = "git-lfs" ;
370- GitExecutablePath = gitInstallPath . Combine ( "bin" , GitExecutable ) ;
371373 GitPackageFeed = packageFeed + $ "mac/{ GitPackageName } ";
372374 GitLfsPackageFeed = packageFeed + $ "mac/{ GitLfsPackageName } ";
373375 }
374- GitLfsExecutablePath = GetGitLfsExecutablePath ( gitInstallPath ) ;
375- }
376-
377- public NPath GetGitLfsExecutablePath ( NPath gitInstallRoot )
378- {
379- return onWindows
380- ? gitInstallRoot . Combine ( "mingw32" , "libexec" , "git-core" , GitLfsExecutable )
381- : gitInstallRoot . Combine ( "libexec" , "git-core" , GitLfsExecutable ) ;
382376 }
383377
384378 public NPath ZipPath { get ; }
385379 public NPath GitZipPath { get ; }
386380 public NPath GitLfsZipPath { get ; }
387381 public NPath GitInstallationPath { get ; }
388- public string GitExecutable { get ; }
382+ public NPath GitLfsInstallationPath { get ; }
389383 public NPath GitExecutablePath { get ; }
390- public string GitLfsExecutable { get ; }
391384 public NPath GitLfsExecutablePath { get ; }
392385 public UriString GitPackageFeed { get ; set ; }
393386 public UriString GitLfsPackageFeed { get ; set ; }
394- public string PackageNameWithVersion => PackageName + "_" + PackageVersion ;
395387 }
396388 }
397389}
0 commit comments