@@ -6,7 +6,8 @@ namespace GitHub.Unity
6
6
{
7
7
class GitInstaller : IGitInstaller
8
8
{
9
- public const string GitLfsExecutableMD5 = "63700E111EF68EE1AD866C2C4373B68D" ;
9
+ public const string WindowsGitLfsExecutableMD5 = "7cfa21e5e9f9819a7cb0c317b0be1c5b" ;
10
+ public const string MacGitLfsExecutableMD5 = "54f586df05a4b80feae4fabed10d8e95" ;
10
11
11
12
private const string PortableGitExpectedVersion = "f02737a78695063deace08e96d5042710d3e32db" ;
12
13
private const string PackageName = "PortableGit" ;
@@ -40,7 +41,7 @@ public GitInstaller(IEnvironment environment, IZipHelper sharpZipLibHelper, Canc
40
41
: ZipHelper . ExtractZipFile ;
41
42
42
43
43
- PackageDestinationDirectory = environment . GetSpecialFolder ( Environment . SpecialFolder . LocalApplicationData )
44
+ GitInstallationPath = environment . GetSpecialFolder ( Environment . SpecialFolder . LocalApplicationData )
44
45
. ToNPath ( ) . Combine ( ApplicationInfo . ApplicationName , PackageNameWithVersion ) ;
45
46
var gitExecutable = "git" ;
46
47
var gitLfsExecutable = "git-lfs" ;
@@ -52,21 +53,21 @@ public GitInstaller(IEnvironment environment, IZipHelper sharpZipLibHelper, Canc
52
53
GitLfsExecutable = gitLfsExecutable ;
53
54
GitExecutable = gitExecutable ;
54
55
55
- GitDestinationPath = PackageDestinationDirectory ;
56
+ GitExecutablePath = GitInstallationPath ;
56
57
if ( DefaultEnvironment . OnWindows )
57
- GitDestinationPath = GitDestinationPath . Combine ( "cmd" ) ;
58
+ GitExecutablePath = GitExecutablePath . Combine ( "cmd" ) ;
58
59
else
59
- GitDestinationPath = GitDestinationPath . Combine ( "bin" ) ;
60
- GitDestinationPath = GitDestinationPath . Combine ( GitExecutable ) ;
60
+ GitExecutablePath = GitExecutablePath . Combine ( "bin" ) ;
61
+ GitExecutablePath = GitExecutablePath . Combine ( GitExecutable ) ;
61
62
62
- GitLfsDestinationPath = PackageDestinationDirectory ;
63
+ GitLfsExecutablePath = GitInstallationPath ;
63
64
64
65
if ( DefaultEnvironment . OnWindows )
65
66
{
66
- GitLfsDestinationPath = GitLfsDestinationPath . Combine ( "mingw32" ) ;
67
+ GitLfsExecutablePath = GitLfsExecutablePath . Combine ( "mingw32" ) ;
67
68
}
68
69
69
- GitLfsDestinationPath = GitLfsDestinationPath . Combine ( "libexec" , "git-core" , GitLfsExecutable ) ;
70
+ GitLfsExecutablePath = GitLfsExecutablePath . Combine ( "libexec" , "git-core" , GitLfsExecutable ) ;
70
71
}
71
72
72
73
public bool IsExtracted ( )
@@ -76,9 +77,9 @@ public bool IsExtracted()
76
77
77
78
private bool IsPortableGitExtracted ( )
78
79
{
79
- if ( ! GitDestinationPath . FileExists ( ) )
80
+ if ( ! GitExecutablePath . FileExists ( ) )
80
81
{
81
- logger . Trace ( "{0} not installed yet" , GitDestinationPath ) ;
82
+ logger . Trace ( "{0} not installed yet" , GitExecutablePath ) ;
82
83
return false ;
83
84
}
84
85
@@ -89,18 +90,18 @@ private bool IsPortableGitExtracted()
89
90
90
91
public bool IsGitLfsExtracted ( )
91
92
{
92
- if ( ! GitLfsDestinationPath . FileExists ( ) )
93
+ if ( ! GitLfsExecutablePath . FileExists ( ) )
93
94
{
94
- logger . Trace ( "{0} not installed yet" , GitLfsDestinationPath ) ;
95
+ logger . Trace ( "{0} not installed yet" , GitLfsExecutablePath ) ;
95
96
return false ;
96
97
}
97
98
98
- var calculateMd5 = environment . FileSystem . CalculateMD5 ( GitLfsDestinationPath ) ;
99
+ var calculateMd5 = environment . FileSystem . CalculateMD5 ( GitLfsExecutablePath ) ;
99
100
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 )
102
103
{
103
- logger . Trace ( "{0} has incorrect MD5" , GitDestinationPath ) ;
104
+ logger . Trace ( "{0} has incorrect MD5" , GitExecutablePath ) ;
104
105
return false ;
105
106
}
106
107
@@ -156,7 +157,7 @@ public Task<bool> SetupGitIfNeeded(NPath tempPath, IProgress<float> zipFileProgr
156
157
157
158
if ( IsPortableGitExtracted ( ) )
158
159
{
159
- logger . Trace ( "Already extracted {0}, returning" , PackageDestinationDirectory ) ;
160
+ logger . Trace ( "Already extracted {0}, returning" , GitInstallationPath ) ;
160
161
return TaskEx . FromResult ( true ) ;
161
162
}
162
163
@@ -196,16 +197,16 @@ public Task<bool> SetupGitIfNeeded(NPath tempPath, IProgress<float> zipFileProgr
196
197
197
198
try
198
199
{
199
- PackageDestinationDirectory . DeleteIfExists ( ) ;
200
- PackageDestinationDirectory . EnsureParentDirectoryExists ( ) ;
200
+ GitInstallationPath . DeleteIfExists ( ) ;
201
+ GitInstallationPath . EnsureParentDirectoryExists ( ) ;
201
202
202
- logger . Trace ( "Moving \" {0}\" to \" {1}\" " , unzipPath , PackageDestinationDirectory ) ;
203
+ logger . Trace ( "Moving \" {0}\" to \" {1}\" " , unzipPath , GitInstallationPath ) ;
203
204
204
- unzipPath . Move ( PackageDestinationDirectory ) ;
205
+ unzipPath . Move ( GitInstallationPath ) ;
205
206
}
206
207
catch ( Exception ex )
207
208
{
208
- logger . Error ( ex , "Error Moving \" {0}\" to \" {1}\" " , tempPath , PackageDestinationDirectory ) ;
209
+ logger . Error ( ex , "Error Moving \" {0}\" to \" {1}\" " , tempPath , GitInstallationPath ) ;
209
210
return TaskEx . FromResult ( false ) ;
210
211
}
211
212
unzipPath . DeleteIfExists ( ) ;
@@ -221,7 +222,7 @@ public Task<bool> SetupGitLfsIfNeeded(NPath tempPath, IProgress<float> zipFilePr
221
222
222
223
if ( IsGitLfsExtracted ( ) )
223
224
{
224
- logger . Trace ( "Already extracted {0}, returning" , GitLfsDestinationPath ) ;
225
+ logger . Trace ( "Already extracted {0}, returning" , GitLfsExecutablePath ) ;
225
226
return TaskEx . FromResult ( false ) ;
226
227
}
227
228
@@ -262,13 +263,13 @@ public Task<bool> SetupGitLfsIfNeeded(NPath tempPath, IProgress<float> zipFilePr
262
263
try
263
264
{
264
265
var unzippedGitLfsExecutablePath = unzipPath . Combine ( GitLfsExecutable ) ;
265
- logger . Trace ( "Copying \" {0}\" to \" {1}\" " , unzippedGitLfsExecutablePath , GitLfsDestinationPath ) ;
266
+ logger . Trace ( "Copying \" {0}\" to \" {1}\" " , unzippedGitLfsExecutablePath , GitLfsExecutablePath ) ;
266
267
267
- unzippedGitLfsExecutablePath . Copy ( GitLfsDestinationPath ) ;
268
+ unzippedGitLfsExecutablePath . Copy ( GitLfsExecutablePath ) ;
268
269
}
269
270
catch ( Exception ex )
270
271
{
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 ) ;
272
273
return TaskEx . FromResult ( false ) ;
273
274
}
274
275
unzipPath . DeleteIfExists ( ) ;
@@ -280,11 +281,11 @@ private NPath GetTemporaryPath()
280
281
return NPath . CreateTempDirectory ( TempPathPrefix ) ;
281
282
}
282
283
283
- public NPath PackageDestinationDirectory { get ; private set ; }
284
+ public NPath GitInstallationPath { get ; private set ; }
284
285
285
- public NPath GitLfsDestinationPath { get ; private set ; }
286
+ public NPath GitLfsExecutablePath { get ; private set ; }
286
287
287
- public NPath GitDestinationPath { get ; private set ; }
288
+ public NPath GitExecutablePath { get ; private set ; }
288
289
public string PackageNameWithVersion => PackageName + "_" + PortableGitExpectedVersion ;
289
290
290
291
private string GitLfsExecutable { get ; set ; }
0 commit comments