@@ -6,7 +6,8 @@ namespace GitHub.Unity
66{
77 class GitInstaller : IGitInstaller
88 {
9- public const string GitLfsExecutableMD5 = "63700E111EF68EE1AD866C2C4373B68D" ;
9+ public const string WindowsGitLfsExecutableMD5 = "7cfa21e5e9f9819a7cb0c317b0be1c5b" ;
10+ public const string MacGitLfsExecutableMD5 = "54f586df05a4b80feae4fabed10d8e95" ;
1011
1112 private const string PortableGitExpectedVersion = "f02737a78695063deace08e96d5042710d3e32db" ;
1213 private const string PackageName = "PortableGit" ;
@@ -40,7 +41,7 @@ public GitInstaller(IEnvironment environment, IZipHelper sharpZipLibHelper, Canc
4041 : ZipHelper . ExtractZipFile ;
4142
4243
43- PackageDestinationDirectory = environment . GetSpecialFolder ( Environment . SpecialFolder . LocalApplicationData )
44+ GitInstallationPath = environment . GetSpecialFolder ( Environment . SpecialFolder . LocalApplicationData )
4445 . ToNPath ( ) . Combine ( ApplicationInfo . ApplicationName , PackageNameWithVersion ) ;
4546 var gitExecutable = "git" ;
4647 var gitLfsExecutable = "git-lfs" ;
@@ -52,21 +53,21 @@ public GitInstaller(IEnvironment environment, IZipHelper sharpZipLibHelper, Canc
5253 GitLfsExecutable = gitLfsExecutable ;
5354 GitExecutable = gitExecutable ;
5455
55- GitDestinationPath = PackageDestinationDirectory ;
56+ GitExecutablePath = GitInstallationPath ;
5657 if ( DefaultEnvironment . OnWindows )
57- GitDestinationPath = GitDestinationPath . Combine ( "cmd" ) ;
58+ GitExecutablePath = GitExecutablePath . Combine ( "cmd" ) ;
5859 else
59- GitDestinationPath = GitDestinationPath . Combine ( "bin" ) ;
60- GitDestinationPath = GitDestinationPath . Combine ( GitExecutable ) ;
60+ GitExecutablePath = GitExecutablePath . Combine ( "bin" ) ;
61+ GitExecutablePath = GitExecutablePath . Combine ( GitExecutable ) ;
6162
62- GitLfsDestinationPath = PackageDestinationDirectory ;
63+ GitLfsExecutablePath = GitInstallationPath ;
6364
6465 if ( DefaultEnvironment . OnWindows )
6566 {
66- GitLfsDestinationPath = GitLfsDestinationPath . Combine ( "mingw32" ) ;
67+ GitLfsExecutablePath = GitLfsExecutablePath . Combine ( "mingw32" ) ;
6768 }
6869
69- GitLfsDestinationPath = GitLfsDestinationPath . Combine ( "libexec" , "git-core" , GitLfsExecutable ) ;
70+ GitLfsExecutablePath = GitLfsExecutablePath . Combine ( "libexec" , "git-core" , GitLfsExecutable ) ;
7071 }
7172
7273 public bool IsExtracted ( )
@@ -76,9 +77,9 @@ public bool IsExtracted()
7677
7778 private bool IsPortableGitExtracted ( )
7879 {
79- if ( ! GitDestinationPath . FileExists ( ) )
80+ if ( ! GitExecutablePath . FileExists ( ) )
8081 {
81- logger . Trace ( "{0} not installed yet" , GitDestinationPath ) ;
82+ logger . Trace ( "{0} not installed yet" , GitExecutablePath ) ;
8283 return false ;
8384 }
8485
@@ -89,18 +90,18 @@ private bool IsPortableGitExtracted()
8990
9091 public bool IsGitLfsExtracted ( )
9192 {
92- if ( ! GitLfsDestinationPath . FileExists ( ) )
93+ if ( ! GitLfsExecutablePath . FileExists ( ) )
9394 {
94- logger . Trace ( "{0} not installed yet" , GitLfsDestinationPath ) ;
95+ logger . Trace ( "{0} not installed yet" , GitLfsExecutablePath ) ;
9596 return false ;
9697 }
9798
98- var calculateMd5 = environment . FileSystem . CalculateMD5 ( GitLfsDestinationPath ) ;
99+ var calculateMd5 = environment . FileSystem . CalculateMD5 ( GitLfsExecutablePath ) ;
99100 logger . Trace ( "GitLFS MD5: {0}" , calculateMd5 ) ;
100-
101- if ( calculateMd5 != GitLfsExecutableMD5 )
101+ var md5 = environment . IsWindows ? WindowsGitLfsExecutableMD5 : MacGitLfsExecutableMD5 ;
102+ if ( String . Compare ( calculateMd5 , md5 , true ) != 0 )
102103 {
103- logger . Trace ( "{0} has incorrect MD5" , GitDestinationPath ) ;
104+ logger . Trace ( "{0} has incorrect MD5" , GitExecutablePath ) ;
104105 return false ;
105106 }
106107
@@ -156,7 +157,7 @@ public Task<bool> SetupGitIfNeeded(NPath tempPath, IProgress<float> zipFileProgr
156157
157158 if ( IsPortableGitExtracted ( ) )
158159 {
159- logger . Trace ( "Already extracted {0}, returning" , PackageDestinationDirectory ) ;
160+ logger . Trace ( "Already extracted {0}, returning" , GitInstallationPath ) ;
160161 return TaskEx . FromResult ( true ) ;
161162 }
162163
@@ -196,16 +197,16 @@ public Task<bool> SetupGitIfNeeded(NPath tempPath, IProgress<float> zipFileProgr
196197
197198 try
198199 {
199- PackageDestinationDirectory . DeleteIfExists ( ) ;
200- PackageDestinationDirectory . EnsureParentDirectoryExists ( ) ;
200+ GitInstallationPath . DeleteIfExists ( ) ;
201+ GitInstallationPath . EnsureParentDirectoryExists ( ) ;
201202
202- logger . Trace ( "Moving \" {0}\" to \" {1}\" " , unzipPath , PackageDestinationDirectory ) ;
203+ logger . Trace ( "Moving \" {0}\" to \" {1}\" " , unzipPath , GitInstallationPath ) ;
203204
204- unzipPath . Move ( PackageDestinationDirectory ) ;
205+ unzipPath . Move ( GitInstallationPath ) ;
205206 }
206207 catch ( Exception ex )
207208 {
208- logger . Error ( ex , "Error Moving \" {0}\" to \" {1}\" " , tempPath , PackageDestinationDirectory ) ;
209+ logger . Error ( ex , "Error Moving \" {0}\" to \" {1}\" " , tempPath , GitInstallationPath ) ;
209210 return TaskEx . FromResult ( false ) ;
210211 }
211212 unzipPath . DeleteIfExists ( ) ;
@@ -221,7 +222,7 @@ public Task<bool> SetupGitLfsIfNeeded(NPath tempPath, IProgress<float> zipFilePr
221222
222223 if ( IsGitLfsExtracted ( ) )
223224 {
224- logger . Trace ( "Already extracted {0}, returning" , GitLfsDestinationPath ) ;
225+ logger . Trace ( "Already extracted {0}, returning" , GitLfsExecutablePath ) ;
225226 return TaskEx . FromResult ( false ) ;
226227 }
227228
@@ -262,13 +263,13 @@ public Task<bool> SetupGitLfsIfNeeded(NPath tempPath, IProgress<float> zipFilePr
262263 try
263264 {
264265 var unzippedGitLfsExecutablePath = unzipPath . Combine ( GitLfsExecutable ) ;
265- logger . Trace ( "Copying \" {0}\" to \" {1}\" " , unzippedGitLfsExecutablePath , GitLfsDestinationPath ) ;
266+ logger . Trace ( "Copying \" {0}\" to \" {1}\" " , unzippedGitLfsExecutablePath , GitLfsExecutablePath ) ;
266267
267- unzippedGitLfsExecutablePath . Copy ( GitLfsDestinationPath ) ;
268+ unzippedGitLfsExecutablePath . Copy ( GitLfsExecutablePath ) ;
268269 }
269270 catch ( Exception ex )
270271 {
271- logger . Error ( ex , "Error Copying git-lfs Source:\" {0}\" Destination:\" {1}\" " , unzipPath , GitLfsDestinationPath ) ;
272+ logger . Error ( ex , "Error Copying git-lfs Source:\" {0}\" Destination:\" {1}\" " , unzipPath , GitLfsExecutablePath ) ;
272273 return TaskEx . FromResult ( false ) ;
273274 }
274275 unzipPath . DeleteIfExists ( ) ;
@@ -280,11 +281,11 @@ private NPath GetTemporaryPath()
280281 return NPath . CreateTempDirectory ( TempPathPrefix ) ;
281282 }
282283
283- public NPath PackageDestinationDirectory { get ; private set ; }
284+ public NPath GitInstallationPath { get ; private set ; }
284285
285- public NPath GitLfsDestinationPath { get ; private set ; }
286+ public NPath GitLfsExecutablePath { get ; private set ; }
286287
287- public NPath GitDestinationPath { get ; private set ; }
288+ public NPath GitExecutablePath { get ; private set ; }
288289 public string PackageNameWithVersion => PackageName + "_" + PortableGitExpectedVersion ;
289290
290291 private string GitLfsExecutable { get ; set ; }
0 commit comments