Skip to content

Commit d3fed83

Browse files
committed
implemented a compacter git invocation for cloning a local repository and setting its remote to the original url
1 parent 8d896c2 commit d3fed83

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

Sources/SourceControl/GitRepository.swift

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,22 +79,13 @@ public class GitRepositoryProvider: RepositoryProvider {
7979
repository: RepositorySpecifier,
8080
at sourcePath: AbsolutePath,
8181
to destinationPath: AbsolutePath,
82-
editable: Bool
82+
editable: Bool = false
8383
) throws {
8484
// For editable clones, i.e. the user is expected to directly work on them, first we create
8585
// a clone from our cache of repositories and then we replace the remote to the one originally
8686
// present in the bare repository.
87-
try Process.checkNonZeroExit(args: Git.tool, "clone", "--no-checkout", sourcePath.pathString, destinationPath.pathString)
88-
// The default name of the remote.
89-
let origin = "origin"
90-
// In destination repo remove the remote which will be pointing to the source repo.
91-
let clone = GitRepository(path: destinationPath)
92-
// Set the original remote to the new clone.
93-
try clone.setURL(remote: origin, url: repository.url)
94-
// FIXME: This is unfortunate that we have to fetch to update remote's data.
95-
try clone.fetch()
96-
// try Process.checkNonZeroExit(args: Git.tool, "clone", "--reference", sourcePath.pathString,
97-
// repository.url, "--dissociate", destinationPath.pathString)
87+
try Process.checkNonZeroExit(args: Git.tool, "clone", "--no-checkout", "--reference", sourcePath.pathString,
88+
repository.url, "--dissociate", destinationPath.pathString)
9889
}
9990

10091
public func checkoutExists(at path: AbsolutePath) throws -> Bool {

0 commit comments

Comments
 (0)