@@ -70,7 +70,6 @@ protected void InitializeEnvironment(NPath repoPath,
70
70
71
71
protected void InitializePlatform ( NPath repoPath ,
72
72
bool enableEnvironmentTrace = true ,
73
- bool setupGit = true ,
74
73
string testName = "" )
75
74
{
76
75
InitializeTaskManager ( ) ;
@@ -79,9 +78,6 @@ protected void InitializePlatform(NPath repoPath,
79
78
ProcessManager = new ProcessManager ( Environment , GitEnvironment , TaskManager . Token ) ;
80
79
81
80
Platform . Initialize ( ProcessManager , TaskManager ) ;
82
-
83
- if ( setupGit )
84
- SetupGit ( Environment . GetSpecialFolder ( System . Environment . SpecialFolder . LocalApplicationData ) . ToNPath ( ) , testName ) ;
85
81
}
86
82
87
83
protected void InitializeTaskManager ( )
@@ -93,12 +89,12 @@ protected void InitializeTaskManager()
93
89
94
90
protected IEnvironment InitializePlatformAndEnvironment ( NPath repoPath ,
95
91
bool enableEnvironmentTrace = false ,
96
- bool setupGit = true ,
97
92
Action < IRepositoryManager > onRepositoryManagerCreated = null ,
98
93
[ CallerMemberName ] string testName = "" )
99
94
{
100
95
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 ) ;
102
98
103
99
DotGitPath = repoPath . Combine ( ".git" ) ;
104
100
@@ -128,38 +124,38 @@ protected IEnvironment InitializePlatformAndEnvironment(NPath repoPath,
128
124
129
125
protected void SetupGit ( NPath pathToSetupGitInto , string testName )
130
126
{
131
- var autoResetEvent = new AutoResetEvent ( false ) ;
132
-
133
127
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 ;
162
129
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 ) ;
163
159
}
164
160
165
161
[ TestFixtureSetUp ]
0 commit comments