Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
overrides:
minimatch@<10.2.1: '>=10.2.1'
Comment thread
fbosch marked this conversation as resolved.
27 changes: 26 additions & 1 deletion src/git/fetch-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,12 +561,37 @@ const handleMissingCache = async (
return { usedCache: false, worktreeUsed: false };
};

const cloneOrUpdateInFlight = new Map<string, Promise<CloneResult>>();

// Clone or update a repository using persistent cache
const cloneOrUpdateRepo = async (
const cloneOrUpdateRepo = (
params: FetchParams,
outDir: string,
): Promise<CloneResult> => {
const cachePath = getPersistentCachePath(params.repo);
const inflight = cloneOrUpdateInFlight.get(cachePath);
if (inflight !== undefined) {
return inflight.then(
() => cloneOrUpdateRepo(params, outDir),
() => cloneOrUpdateRepo(params, outDir),
);
Comment thread
fbosch marked this conversation as resolved.
Outdated
Comment thread
fbosch marked this conversation as resolved.
Outdated
}
const promise = (async () => {
try {
return await cloneOrUpdateRepoImpl(params, outDir, cachePath);
} finally {
cloneOrUpdateInFlight.delete(cachePath);
}
})();
cloneOrUpdateInFlight.set(cachePath, promise);
return promise;
};
Comment thread
fbosch marked this conversation as resolved.
Comment thread
fbosch marked this conversation as resolved.

const cloneOrUpdateRepoImpl = async (
params: FetchParams,
outDir: string,
cachePath: string,
): Promise<CloneResult> => {
const cacheExists = await exists(cachePath);
const cacheValid = cacheExists && (await isValidGitRepo(cachePath));
const isCommitRef = /^[0-9a-f]{7,40}$/i.test(params.ref);
Expand Down
Loading