@@ -70,7 +70,6 @@ protected void InitializeEnvironment(NPath repoPath,
7070
7171 protected void InitializePlatform ( NPath repoPath ,
7272 bool enableEnvironmentTrace = true ,
73- bool setupGit = true ,
7473 string testName = "" )
7574 {
7675 InitializeTaskManager ( ) ;
@@ -79,9 +78,6 @@ protected void InitializePlatform(NPath repoPath,
7978 ProcessManager = new ProcessManager ( Environment , GitEnvironment , TaskManager . Token ) ;
8079
8180 Platform . Initialize ( ProcessManager , TaskManager ) ;
82-
83- if ( setupGit )
84- SetupGit ( Environment . GetSpecialFolder ( System . Environment . SpecialFolder . LocalApplicationData ) . ToNPath ( ) , testName ) ;
8581 }
8682
8783 protected void InitializeTaskManager ( )
@@ -93,12 +89,12 @@ protected void InitializeTaskManager()
9389
9490 protected IEnvironment InitializePlatformAndEnvironment ( NPath repoPath ,
9591 bool enableEnvironmentTrace = false ,
96- bool setupGit = true ,
9792 Action < IRepositoryManager > onRepositoryManagerCreated = null ,
9893 [ CallerMemberName ] string testName = "" )
9994 {
10095 InitializeEnvironment ( repoPath , enableEnvironmentTrace , true ) ;
101- InitializePlatform ( repoPath , enableEnvironmentTrace : enableEnvironmentTrace , setupGit : setupGit , testName : testName ) ;
96+ InitializePlatform ( repoPath , enableEnvironmentTrace : enableEnvironmentTrace , testName : testName ) ;
97+ SetupGit ( Environment . GetSpecialFolder ( System . Environment . SpecialFolder . LocalApplicationData ) . ToNPath ( ) , testName ) ;
10298
10399 DotGitPath = repoPath . Combine ( ".git" ) ;
104100
@@ -128,38 +124,38 @@ protected IEnvironment InitializePlatformAndEnvironment(NPath repoPath,
128124
129125 protected void SetupGit ( NPath pathToSetupGitInto , string testName )
130126 {
131- var autoResetEvent = new AutoResetEvent ( false ) ;
132-
133127 var installDetails = new GitInstaller . GitInstallDetails ( pathToSetupGitInto , Environment . IsWindows ) ;
134-
135- var zipArchivesPath = pathToSetupGitInto . Combine ( "downloads" ) . CreateDirectory ( ) ;
136-
137- Logger . Trace ( $ "Saving git zips into { zipArchivesPath } and unzipping to { pathToSetupGitInto } ") ;
138-
139- AssemblyResources . ToFile ( ResourceType . Platform , "git.zip" , zipArchivesPath , Environment ) ;
140- AssemblyResources . ToFile ( ResourceType . Platform , "git.zip.md5" , zipArchivesPath , Environment ) ;
141- AssemblyResources . ToFile ( ResourceType . Platform , "git-lfs.zip" , zipArchivesPath , Environment ) ;
142- AssemblyResources . ToFile ( ResourceType . Platform , "git-lfs.zip.md5" , zipArchivesPath , Environment ) ;
143-
144- var gitInstaller = new GitInstaller ( Environment , ProcessManager , TaskManager . Token , null , installDetails : installDetails ) ;
145-
146- Exception ex = null ;
147-
148- var state = gitInstaller . SetupGitIfNeeded ( ) ;
149- var result = state . GitExecutablePath ;
150-
151- if ( ! result . IsInitialized )
152- {
153- if ( ex != null )
154- {
155- throw ex ;
156- }
157-
158- throw new Exception ( "Did not install git" ) ;
159- }
160-
161- Environment . GitExecutablePath = result ;
128+ Environment . GitExecutablePath = installDetails . GitExecutablePath ;
162129 GitClient = new GitClient ( Environment , ProcessManager , TaskManager . Token ) ;
130+
131+ if ( installDetails . GitExecutablePath . FileExists ( ) && installDetails . GitLfsExecutablePath . FileExists ( ) )
132+ return ;
133+
134+ installDetails . GitInstallationPath . DeleteIfExists ( ) ;
135+
136+ installDetails . GitZipPath . EnsureParentDirectoryExists ( ) ;
137+ installDetails . GitLfsZipPath . EnsureParentDirectoryExists ( ) ;
138+
139+ AssemblyResources . ToFile ( ResourceType . Platform , "git.zip" , installDetails . GitZipPath . Parent , Environment ) ;
140+ AssemblyResources . ToFile ( ResourceType . Platform , "git.json" , installDetails . GitZipPath . Parent , Environment ) ;
141+ AssemblyResources . ToFile ( ResourceType . Platform , "git-lfs.zip" , installDetails . GitZipPath . Parent , Environment ) ;
142+ AssemblyResources . ToFile ( ResourceType . Platform , "git-lfs.json" , installDetails . GitZipPath . Parent , Environment ) ;
143+
144+ var tempZipExtractPath = TestBasePath . Combine ( "setup" , "git_zip_extract_zip_paths" ) . EnsureDirectoryExists ( ) ;
145+ var extractPath = tempZipExtractPath . Combine ( "git" ) . CreateDirectory ( ) ;
146+ var path = new UnzipTask ( TaskManager . Token , installDetails . GitZipPath , extractPath , null , Environment . FileSystem )
147+ . Catch ( e => true )
148+ . RunWithReturn ( true ) ;
149+ var source = path ;
150+ installDetails . GitInstallationPath . EnsureParentDirectoryExists ( ) ;
151+ source . Move ( installDetails . GitInstallationPath ) ;
152+
153+ extractPath = tempZipExtractPath . Combine ( "git-lfs" ) . CreateDirectory ( ) ;
154+ path = new UnzipTask ( TaskManager . Token , installDetails . GitLfsZipPath , extractPath , null , Environment . FileSystem )
155+ . Catch ( e => true )
156+ . RunWithReturn ( true ) ;
157+ source = path . Combine ( installDetails . GitLfsExecutable ) ;
158+ source . Move ( installDetails . GitLfsExecutablePath ) ;
163159 }
164160
165161 [ TestFixtureSetUp ]
0 commit comments