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

Commit dd94727

Browse files
committed
Only open repository when .git directory exists
We don't want to change context when a clone operation has failed.
1 parent 9885bad commit dd94727

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/GitHub.Exports/Services/VSServices.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ public bool TryOpenRepository(string repoPath)
7878
return false;
7979
}
8080

81-
var repoDir = os.Directory.GetDirectory(repoPath);
82-
if (!repoDir.Exists)
81+
var gitPath = Path.Combine(repoPath, ".git");
82+
var gitDir = os.Directory.GetDirectory(gitPath);
83+
if (!gitDir.Exists)
8384
{
8485
return false;
8586
}

test/GitHub.Exports.UnitTests/VSServicesTests.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,10 @@ VSServices CreateVSServices(string repoDir, IOperatingSystem os = null, DTE dte
9292

9393
if (repoDir != null)
9494
{
95+
var gitDir = Path.Combine(repoDir, ".git");
9596
var directoryInfo = Substitute.For<IDirectoryInfo>();
9697
directoryInfo.Exists.Returns(repoDirExists);
97-
os.Directory.GetDirectory(repoDir).Returns(directoryInfo);
98+
os.Directory.GetDirectory(gitDir).Returns(directoryInfo);
9899
}
99100

100101
var provider = Substitute.For<IGitHubServiceProvider>();

0 commit comments

Comments
 (0)