Skip to content

Commit 124c6af

Browse files
committed
Fix checkoutExists and add test for it
1 parent 81040c9 commit 124c6af

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

Sources/SourceControl/GitRepository.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public class GitRepositoryProvider: RepositoryProvider {
9595
public func checkoutExists(at path: AbsolutePath) throws -> Bool {
9696
precondition(exists(path))
9797

98-
let result = try Process.popen(args: Git.tool, "rev-parse", "--is-bare-repository")
98+
let result = try Process.popen(args: Git.tool, "-C", path.asString, "rev-parse", "--is-bare-repository")
9999
return try result.exitStatus == .terminated(code: 0) && result.utf8Output().chomp() == "false"
100100
}
101101

Tests/SourceControlTests/GitRepositoryTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class GitRepositoryTests: XCTestCase {
4040
// Test the provider.
4141
let testCheckoutPath = path.appending(component: "checkout")
4242
let provider = GitRepositoryProvider()
43+
XCTAssertTrue(try provider.checkoutExists(at: testRepoPath))
4344
let repoSpec = RepositorySpecifier(url: testRepoPath.asString)
4445
try! provider.fetch(repository: repoSpec, to: testCheckoutPath)
4546

0 commit comments

Comments
 (0)