Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 670b185

Browse files
grokysJasmine
authored andcommitted
Just test for existing directory on creation view.
Rather than .git/HEAD
1 parent a45847e commit 670b185

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

src/GitHub.App/ViewModels/RepositoryCreationViewModel.cs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -253,23 +253,11 @@ bool IsAlreadyRepoAtPath(string potentialRepositoryName)
253253
if (Path.GetInvalidPathChars().Any(chr => BaseRepositoryPath.Contains(chr)))
254254
return false;
255255
string potentialPath = Path.Combine(BaseRepositoryPath, safeRepositoryName);
256-
isAlreadyRepoAtPath = IsGitRepo(potentialPath);
256+
isAlreadyRepoAtPath = operatingSystem.Directory.Exists(potentialPath);
257257
}
258258
return isAlreadyRepoAtPath;
259259
}
260260

261-
bool IsGitRepo(string path)
262-
{
263-
try
264-
{
265-
return operatingSystem.File.Exists(Path.Combine(path, ".git", "HEAD"));
266-
}
267-
catch (PathTooLongException)
268-
{
269-
return false;
270-
}
271-
}
272-
273261
IObservable<Unit> OnCreateRepository(object state)
274262
{
275263
var newRepository = GatherRepositoryInfo();

src/UnitTests/GitHub.App/ViewModels/RepositoryCreationViewModelTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ public void IsFalseWhenRepositoryAlreadyExists(bool exists, bool expected)
281281
{
282282
var provider = Substitutes.ServiceProvider;
283283
var operatingSystem = provider.GetOperatingSystem();
284-
operatingSystem.File.Exists(@"c:\fake\foo\.git\HEAD").Returns(exists);
284+
operatingSystem.Directory.Exists(@"c:\fake\foo").Returns(exists);
285285
var vm = GetMeAViewModel(provider);
286286
vm.BaseRepositoryPath = @"c:\fake\";
287287

0 commit comments

Comments
 (0)