diff --git a/Sources/SourceControl/GitRepository.swift b/Sources/SourceControl/GitRepository.swift index 963570b1834..2781413db10 100644 --- a/Sources/SourceControl/GitRepository.swift +++ b/Sources/SourceControl/GitRepository.swift @@ -211,7 +211,7 @@ public struct GitRepositoryProvider: RepositoryProvider, Cancellable { } public func isValidDirectory(_ directory: Basics.AbsolutePath, for repository: RepositorySpecifier) throws -> Bool { - let remoteURL = try self.git.run(["-C", directory.pathString, "remote", "get-url", "origin"]) + let remoteURL = try self.git.run(["-C", directory.pathString, "config", "--get", "remote.origin.url"]) return remoteURL == repository.url } diff --git a/Sources/SourceControl/RepositoryManager.swift b/Sources/SourceControl/RepositoryManager.swift index cecd9da1d11..4d31db93c9e 100644 --- a/Sources/SourceControl/RepositoryManager.swift +++ b/Sources/SourceControl/RepositoryManager.swift @@ -202,7 +202,7 @@ public class RepositoryManager: Cancellable { // and recoverable, and as such can be ignored quick: if (try? self.provider.repositoryExists(at: repositoryPath)) ?? false { let repository = try handle.open() - + guard ((try? self.provider.isValidDirectory(repositoryPath, for: repositorySpecifier)) ?? false) else { observabilityScope.emit(warning: "\(repositoryPath) is not valid git repository for '\(repositorySpecifier.location)', will fetch again.") break quick