@@ -111,45 +111,51 @@ public void SetupGitIfNeeded(ActionTask<NPath> onSuccess, ITask onFailure)
111
111
return ;
112
112
}
113
113
114
- new ActionTask ( cancellationToken , ( ) => {
115
- if ( IsGitExtracted ( ) )
114
+ var task = new FuncTask < NPath > ( cancellationToken , ( ) =>
115
+ {
116
+ if ( ! IsGitExtracted ( ) )
116
117
{
117
118
Logger . Trace ( "SetupGitIfNeeded: Skipped" ) ;
118
- onSuccess . PreviousResult = installDetails . GitExecutablePath ;
119
- onSuccess . Start ( ) ;
120
- }
121
- else
122
- {
123
- ExtractPortableGit ( onSuccess , onFailure ) ;
119
+ throw new Exception ( ) ;
124
120
}
125
- } ) . Start ( ) ;
121
+ return installDetails . GitExecutablePath ;
122
+ } ) ;
123
+ var extractTask = ExtractPortableGit ( ) ;
124
+ extractTask . Then ( onSuccess , TaskRunOptions . OnSuccess , taskIsTopOfChain : true ) ;
125
+ extractTask . Then ( onFailure , TaskRunOptions . OnFailure , taskIsTopOfChain : true ) ;
126
+
127
+ task . Then ( onSuccess , TaskRunOptions . OnSuccess , taskIsTopOfChain : true ) ;
128
+ task . Then ( extractTask , TaskRunOptions . OnFailure , taskIsTopOfChain : true ) ;
129
+ task . Start ( ) ;
126
130
}
127
131
128
- private void ExtractPortableGit ( ActionTask < NPath > onSuccess , ITask onFailure )
132
+ private FuncTask < NPath > ExtractPortableGit ( )
129
133
{
130
- ITask downloadFilesTask = null ;
131
- if ( ( gitArchiveFilePath == null ) || ( gitLfsArchivePath == null ) )
132
- {
133
- downloadFilesTask = CreateDownloadTask ( ) ;
134
- }
135
-
136
134
var tempZipExtractPath = NPath . CreateTempDirectory ( "git_zip_extract_zip_paths" ) ;
137
135
var gitExtractPath = tempZipExtractPath . Combine ( "git" ) . CreateDirectory ( ) ;
138
136
var gitLfsExtractPath = tempZipExtractPath . Combine ( "git-lfs" ) . CreateDirectory ( ) ;
139
137
140
- var resultTask = new UnzipTask ( cancellationToken , gitArchiveFilePath , gitExtractPath , sharpZipLibHelper , environment . FileSystem , GitInstallDetails . GitExtractedMD5 )
141
- . Then ( new UnzipTask ( cancellationToken , gitLfsArchivePath , gitLfsExtractPath , sharpZipLibHelper , environment . FileSystem , GitInstallDetails . GitLfsExtractedMD5 ) )
142
- . Then ( s => MoveGitAndLfs ( gitExtractPath , gitLfsExtractPath , tempZipExtractPath ) ) ;
143
-
144
- resultTask . Then ( onFailure , TaskRunOptions . OnFailure ) ;
145
- resultTask . Then ( onSuccess , TaskRunOptions . OnSuccess ) ;
138
+ var unzipTasks = CreateUnzipTasks ( gitExtractPath , gitLfsExtractPath , tempZipExtractPath ) ;
146
139
147
- if ( downloadFilesTask ! = null )
140
+ if ( gitArchiveFilePath == null || gitLfsArchivePath = = null )
148
141
{
149
- resultTask = downloadFilesTask . Then ( resultTask ) ;
142
+ var downloadFilesTask = CreateDownloadTask ( ) ;
143
+ unzipTasks = downloadFilesTask . Then ( unzipTasks ) ;
150
144
}
151
145
152
- resultTask . Start ( ) ;
146
+ return unzipTasks ;
147
+ }
148
+
149
+ private FuncTask < NPath > CreateUnzipTasks ( NPath gitExtractPath , NPath gitLfsExtractPath , NPath tempZipExtractPath )
150
+ {
151
+ var unzipGitTask = new UnzipTask ( cancellationToken , gitArchiveFilePath , gitExtractPath , sharpZipLibHelper ,
152
+ environment . FileSystem , GitInstallDetails . GitExtractedMD5 ) ;
153
+ var unzipGitLfsTask = new UnzipTask ( cancellationToken , gitLfsArchivePath , gitLfsExtractPath , sharpZipLibHelper ,
154
+ environment . FileSystem , GitInstallDetails . GitLfsExtractedMD5 ) ;
155
+ var moveGitTask = new FuncTask < NPath > ( cancellationToken , ( ) => MoveGitAndLfs ( gitExtractPath , gitLfsExtractPath , tempZipExtractPath ) ) ;
156
+ return unzipGitTask
157
+ . Then ( unzipGitLfsTask )
158
+ . Then ( moveGitTask ) ;
153
159
}
154
160
155
161
private NPath MoveGitAndLfs ( NPath gitExtractPath , NPath gitLfsExtractPath , NPath tempZipExtractPath )
0 commit comments