Skip to content

Commit c9d0567

Browse files
committed
deferred purging of the cache
1 parent 94b2eed commit c9d0567

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

Sources/SourceControl/GitRepository.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ public class GitRepositoryProvider: RepositoryProvider {
132132
// NOTE: We intentionally do not create a shallow clone here; the
133133
// expected cost of iterative updates on a full clone is less than on a
134134
// shallow clone.
135+
defer { purgeCacheIfNeeded() }
135136

136137
precondition(!localFileSystem.exists(path))
137138

@@ -140,14 +141,12 @@ public class GitRepositoryProvider: RepositoryProvider {
140141

141142
let process: Process
142143

143-
if let cache = setupCacheIfNeeded(for: repository),
144-
URL.scheme(repository.url) == "ssh" || URL.scheme(repository.url) == "https" {
144+
if let cache = setupCacheIfNeeded(for: repository) {
145145
// Clone the repository using the cache as a reference if possible.
146146
// Git objects are not shared (--dissociate) to avoid problems that might occur when the cache is
147147
// deleted or the package is copied somewhere it cannot reach the cache directory.
148148
process = Process(args: Git.tool, "clone", "--reference", cache.path.pathString, "--dissociate",
149149
"--mirror", repository.url, path.pathString, environment: Git.environment)
150-
purgeCacheIfNeeded()
151150
} else {
152151
process = Process(args: Git.tool, "clone", "--mirror",
153152
repository.url, path.pathString, environment: Git.environment)

0 commit comments

Comments
 (0)