@@ -11,6 +11,16 @@ class GitInstallDetails
11
11
public NPath GitExecPath { get ; }
12
12
public string GitLfsExec { get ; }
13
13
public NPath GitLfsExecPath { get ; }
14
+ public UriString GitZipMd5Url { get ; set ; } = DefaultGitZipMd5Url ;
15
+ public UriString GitZipUrl { get ; set ; } = DefaultGitZipUrl ;
16
+ public UriString GitLfsZipMd5Url { get ; set ; } = DefaultGitLfsZipMd5Url ;
17
+ public UriString GitLfsZipUrl { get ; set ; } = DefaultGitLfsZipUrl ;
18
+
19
+ public const string DefaultGitZipMd5Url = "https://ghfvs-installer.github.com/unity/portable_git/git.zip.MD5.txt" ;
20
+ public const string DefaultGitZipUrl = "https://ghfvs-installer.github.com/unity/portable_git/git.zip" ;
21
+ public const string DefaultGitLfsZipMd5Url = "https://ghfvs-installer.github.com/unity/portable_git/git-lfs.zip.MD5.txt" ;
22
+ public const string DefaultGitLfsZipUrl = "https://ghfvs-installer.github.com/unity/portable_git/git-lfs.zip" ;
23
+
14
24
15
25
public const string GitExtractedMD5 = "e6cfc0c294a2312042f27f893dfc9c0a" ;
16
26
public const string GitLfsExtractedMD5 = "36e3ae968b69fbf42dff72311040d24a" ;
@@ -99,102 +109,91 @@ public void SetupGitIfNeeded(ActionTask<NPath> onSuccess, ITask onFailure)
99
109
return ;
100
110
}
101
111
102
- new FuncTask < bool > ( cancellationToken , IsGitExtracted )
103
- . Finally ( ( success , ex , isPortableGitExtracted ) => {
104
- Logger . Trace ( "IsPortableGitExtracted: {0}" , isPortableGitExtracted ) ;
105
-
106
- if ( isPortableGitExtracted )
107
- {
108
- Logger . Trace ( "SetupGitIfNeeded: Skipped" ) ;
109
-
110
- new FuncTask < NPath > ( cancellationToken , ( ) => installDetails . GitExecPath )
111
- . Then ( onSuccess )
112
- . Start ( ) ;
113
- }
114
- else
115
- {
116
- ITask downloadFilesTask = null ;
117
- if ( gitArchiveFilePath == null || gitLfsArchivePath == null )
118
- {
119
- downloadFilesTask = CreateDownloadTask ( ) ;
120
- }
121
-
122
- var tempZipExtractPath = NPath . CreateTempDirectory ( "git_zip_extract_zip_paths" ) ;
123
- var gitExtractPath = tempZipExtractPath . Combine ( "git" ) . CreateDirectory ( ) ;
124
- var gitLfsExtractPath = tempZipExtractPath . Combine ( "git-lfs" ) . CreateDirectory ( ) ;
125
-
126
- var resultTask = new UnzipTask ( cancellationToken , gitArchiveFilePath , gitExtractPath , sharpZipLibHelper , environment . FileSystem , GitInstallDetails . GitExtractedMD5 )
127
- . Then ( new UnzipTask ( cancellationToken , gitLfsArchivePath , gitLfsExtractPath , sharpZipLibHelper , environment . FileSystem , GitInstallDetails . GitLfsExtractedMD5 ) )
128
- . Then ( ( ) => {
129
- var targetGitLfsExecPath = installDetails . GetGitLfsExecPath ( gitExtractPath ) ;
130
- var extractGitLfsExePath = gitLfsExtractPath . Combine ( installDetails . GitLfsExec ) ;
131
-
132
- Logger . Trace ( "Moving Git LFS Exe:\" {0}\" to target in tempDirectory:\" {1}\" " , extractGitLfsExePath ,
133
- targetGitLfsExecPath ) ;
134
-
135
- extractGitLfsExePath . Move ( targetGitLfsExecPath ) ;
136
-
137
- Logger . Trace ( "Moving tempDirectory:\" {0}\" to extractTarget:\" {1}\" " , gitExtractPath ,
138
- installDetails . GitInstallPath ) ;
139
-
140
- installDetails . GitInstallPath . EnsureParentDirectoryExists ( ) ;
141
- gitExtractPath . Move ( installDetails . GitInstallPath ) ;
142
-
143
- Logger . Trace ( "Deleting targetGitLfsExecPath:\" {0}\" " , targetGitLfsExecPath ) ;
144
- targetGitLfsExecPath . DeleteIfExists ( ) ;
145
-
146
- Logger . Trace ( "Deleting tempZipPath:\" {0}\" " , tempZipExtractPath ) ;
147
- tempZipExtractPath . DeleteIfExists ( ) ;
148
- } )
149
- . Finally ( ( b , exception ) => {
150
- if ( b )
151
- {
152
- Logger . Trace ( "SetupGitIfNeeded: Success" ) ;
153
-
154
- new FuncTask < NPath > ( cancellationToken , ( ) => installDetails . GitExecPath )
155
- . Then ( onSuccess )
156
- . Start ( ) ;
157
- }
158
- else
159
- {
160
- Logger . Warning ( "SetupGitIfNeeded: Failed" ) ;
161
-
162
- onFailure . Start ( ) ;
163
- }
164
- } ) ;
165
-
166
- if ( downloadFilesTask != null )
167
- {
168
- resultTask = downloadFilesTask . Then ( resultTask ) ;
169
- }
170
-
171
- resultTask . Start ( ) ;
172
- }
173
- } ) . Start ( ) ;
112
+ new ActionTask ( cancellationToken , ( ) => {
113
+ if ( IsGitExtracted ( ) )
114
+ {
115
+ Logger . Trace ( "SetupGitIfNeeded: Skipped" ) ;
116
+ onSuccess . PreviousResult = installDetails . GitExecPath ;
117
+ onSuccess . Start ( ) ;
118
+ }
119
+ else
120
+ {
121
+ ExtractPortableGit ( onSuccess , onFailure ) ;
122
+ }
123
+ } ) . Start ( ) ;
124
+ }
125
+
126
+ private void ExtractPortableGit ( ActionTask < NPath > onSuccess , ITask onFailure )
127
+ {
128
+ ITask downloadFilesTask = null ;
129
+ if ( gitArchiveFilePath == null || gitLfsArchivePath == null )
130
+ {
131
+ downloadFilesTask = CreateDownloadTask ( ) ;
132
+ }
133
+
134
+ var tempZipExtractPath = NPath . CreateTempDirectory ( "git_zip_extract_zip_paths" ) ;
135
+ var gitExtractPath = tempZipExtractPath . Combine ( "git" ) . CreateDirectory ( ) ;
136
+ var gitLfsExtractPath = tempZipExtractPath . Combine ( "git-lfs" ) . CreateDirectory ( ) ;
137
+
138
+ var resultTask = new UnzipTask ( cancellationToken , gitArchiveFilePath , gitExtractPath , sharpZipLibHelper , environment . FileSystem , GitInstallDetails . GitExtractedMD5 )
139
+ . Then ( new UnzipTask ( cancellationToken , gitLfsArchivePath , gitLfsExtractPath , sharpZipLibHelper , environment . FileSystem , GitInstallDetails . GitLfsExtractedMD5 ) )
140
+ . Then ( s =>
141
+ {
142
+ var targetGitLfsExecPath = installDetails . GetGitLfsExecPath ( gitExtractPath ) ;
143
+ var extractGitLfsExePath = gitLfsExtractPath . Combine ( installDetails . GitLfsExec ) ;
144
+
145
+ Logger . Trace ( "Moving Git LFS Exe:\" {0}\" to target in tempDirectory:\" {1}\" " , extractGitLfsExePath ,
146
+ targetGitLfsExecPath ) ;
147
+
148
+ extractGitLfsExePath . Move ( targetGitLfsExecPath ) ;
149
+
150
+ Logger . Trace ( "Moving tempDirectory:\" {0}\" to extractTarget:\" {1}\" " , gitExtractPath ,
151
+ installDetails . GitInstallPath ) ;
152
+
153
+ installDetails . GitInstallPath . EnsureParentDirectoryExists ( ) ;
154
+ gitExtractPath . Move ( installDetails . GitInstallPath ) ;
155
+
156
+ Logger . Trace ( "Deleting targetGitLfsExecPath:\" {0}\" " , targetGitLfsExecPath ) ;
157
+ targetGitLfsExecPath . DeleteIfExists ( ) ;
158
+
159
+ Logger . Trace ( "Deleting tempZipPath:\" {0}\" " , tempZipExtractPath ) ;
160
+ tempZipExtractPath . DeleteIfExists ( ) ;
161
+ return installDetails . GitExecPath ;
162
+ } ) ;
163
+
164
+ resultTask . Then ( onFailure , TaskRunOptions . OnFailure ) ;
165
+ resultTask . Then ( onSuccess , TaskRunOptions . OnSuccess ) ;
166
+
167
+ if ( downloadFilesTask != null )
168
+ {
169
+ resultTask = downloadFilesTask . Then ( resultTask ) ;
170
+ }
171
+
172
+ resultTask . Start ( ) ;
174
173
}
175
174
176
175
private ITask CreateDownloadTask ( )
177
176
{
178
177
var tempZipPath = NPath . CreateTempDirectory ( "git_zip_paths" ) ;
179
- gitArchiveFilePath = tempZipPath . Combine ( "git" ) ;
180
- gitLfsArchivePath = tempZipPath . Combine ( "git-lfs" ) ;
178
+ gitArchiveFilePath = tempZipPath . Combine ( "git.zip " ) ;
179
+ gitLfsArchivePath = tempZipPath . Combine ( "git-lfs.zip " ) ;
181
180
182
181
var downloadGitMd5Task = new DownloadTextTask ( TaskManager . Instance . Token ,
183
182
environment . FileSystem ,
184
- "https://ghfvs-installer.github.com/unity/portable_git/git.zip.MD5.txt" ,
185
- gitArchiveFilePath ) ;
183
+ installDetails . GitZipMd5Url ,
184
+ tempZipPath ) ;
186
185
187
186
var downloadGitTask = new DownloadTask ( TaskManager . Instance . Token , environment . FileSystem ,
188
- "https://ghfvs-installer.github.com/unity/portable_git/git.zip" ,
189
- gitArchiveFilePath , retryCount : 1 ) ;
187
+ installDetails . GitZipUrl ,
188
+ tempZipPath ) ;
190
189
191
190
var downloadGitLfsMd5Task = new DownloadTextTask ( TaskManager . Instance . Token , environment . FileSystem ,
192
- "https://ghfvs-installer.github.com/unity/portable_git/git-lfs.zip.MD5.txt" ,
193
- gitLfsArchivePath ) ;
191
+ installDetails . GitLfsZipMd5Url ,
192
+ tempZipPath ) ;
194
193
195
194
var downloadGitLfsTask = new DownloadTask ( TaskManager . Instance . Token , environment . FileSystem ,
196
- "https://ghfvs-installer.github.com/unity/portable_git/git-lfs.zip" ,
197
- gitLfsArchivePath , retryCount : 1 ) ;
195
+ installDetails . GitLfsZipUrl ,
196
+ tempZipPath ) ;
198
197
199
198
return downloadGitMd5Task
200
199
. Then ( ( b , s ) => {
0 commit comments