This repository was archived by the owner on Jun 21, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +6
-18
lines changed
UnitTests/GitHub.App/ViewModels Expand file tree Collapse file tree 2 files changed +6
-18
lines changed Original file line number Diff line number Diff line change @@ -153,7 +153,7 @@ IObservable<Unit> OnCloneRepository(object state)
153153 } ) ;
154154 }
155155
156- bool IsAlreadyRepoAtPath ( string baseRepositoryPath )
156+ bool IsAlreadyRepoAtPath ( string path )
157157 {
158158 bool isAlreadyRepoAtPath = false ;
159159
@@ -162,26 +162,14 @@ bool IsAlreadyRepoAtPath(string baseRepositoryPath)
162162 var validationResult = BaseRepositoryPathValidator . ValidationResult ;
163163 if ( validationResult != null && validationResult . IsValid )
164164 {
165- string potentialPath = Path . Combine ( baseRepositoryPath , SelectedRepository . Name ) ;
166- isAlreadyRepoAtPath = IsGitRepo ( potentialPath ) ;
165+ string potentialPath = Path . Combine ( path , SelectedRepository . Name ) ;
166+ isAlreadyRepoAtPath = operatingSystem . Directory . Exists ( potentialPath ) ;
167167 }
168168 }
169169
170170 return isAlreadyRepoAtPath ;
171171 }
172172
173- bool IsGitRepo ( string path )
174- {
175- try
176- {
177- return operatingSystem . File . Exists ( Path . Combine ( path , ".git" , "HEAD" ) ) ;
178- }
179- catch ( PathTooLongException )
180- {
181- return false ;
182- }
183- }
184-
185173 /// <summary>
186174 /// Path to clone repositories into
187175 /// </summary>
Original file line number Diff line number Diff line change @@ -208,9 +208,9 @@ public void IsInvalidWhenDestinationRepositoryExists()
208208 repositoryHost . ModelService . GetRepositories ( ) . Returns ( Observable . Return ( new [ ] { repo } ) ) ;
209209 var cloneService = Substitute . For < IRepositoryCloneService > ( ) ;
210210 var os = Substitute . For < IOperatingSystem > ( ) ;
211- var files = Substitute . For < IFileFacade > ( ) ;
212- os . File . Returns ( files ) ;
213- files . Exists ( @"c:\foo\bar\.git\HEAD " ) . Returns ( true ) ;
211+ var directories = Substitute . For < IDirectoryFacade > ( ) ;
212+ os . Directory . Returns ( directories ) ;
213+ directories . Exists ( @"c:\foo\bar" ) . Returns ( true ) ;
214214 var vm = new RepositoryCloneViewModel (
215215 repositoryHost ,
216216 cloneService ,
You can’t perform that action at this time.
0 commit comments