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

Commit 91ec2c4

Browse files
committed
Just test for existing directory on creation view.
Rather than .git/HEAD
1 parent 0ac4354 commit 91ec2c4

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
@@ -283,7 +283,7 @@ public void IsFalseWhenRepositoryAlreadyExists(bool exists, bool expected)
283283
{
284284
var provider = Substitutes.ServiceProvider;
285285
var operatingSystem = provider.GetOperatingSystem();
286-
operatingSystem.File.Exists(@"c:\fake\foo\.git\HEAD").Returns(exists);
286+
operatingSystem.Directory.Exists(@"c:\fake\foo").Returns(exists);
287287
var vm = GetMeAViewModel(provider);
288288
vm.BaseRepositoryPath = @"c:\fake\";
289289

0 commit comments

Comments
 (0)