Skip to content

Commit 8db109f

Browse files
authored
Merge pull request #6 from AztecProtocol/fix/gc-race-condition
fix: disable gc.auto after blobless clones to prevent race condition
2 parents 1f55df8 + 19f941c commit 8db109f

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

src/utils/git.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export async function cloneRepo(
7676
]);
7777

7878
const repoGit = simpleGit(repoPath);
79+
await repoGit.raw(["config", "gc.auto", "0"]);
7980
await repoGit.raw(["sparse-checkout", "set", ...config.sparse]);
8081
await repoGit.fetch(["origin", config.commit]);
8182
await repoGit.checkout(config.commit);
@@ -87,6 +88,7 @@ export async function cloneRepo(
8788
]);
8889

8990
const repoGit = simpleGit(repoPath);
91+
await repoGit.raw(["config", "gc.auto", "0"]);
9092
await repoGit.raw(["sparse-checkout", "set", ...config.sparse]);
9193
await repoGit.fetch(["--depth=1", "origin", `refs/tags/${config.tag}:refs/tags/${config.tag}`]);
9294
await repoGit.checkout(config.tag);
@@ -117,6 +119,7 @@ export async function cloneRepo(
117119
]);
118120

119121
const repoGit = simpleGit(repoPath);
122+
await repoGit.raw(["config", "gc.auto", "0"]);
120123
await repoGit.raw(["sparse-checkout", "set", ...config.sparse]);
121124
}
122125

tests/utils/git.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ describe("cloneRepo", () => {
132132
expect.stringContaining("aztec-packages"),
133133
expect.arrayContaining(["--filter=blob:none", "--sparse", "--no-checkout"])
134134
);
135+
expect(mockGitInstance.raw).toHaveBeenCalledWith(["config", "gc.auto", "0"]);
135136
expect(mockGitInstance.raw).toHaveBeenCalledWith([
136137
"sparse-checkout",
137138
"set",
@@ -240,6 +241,7 @@ describe("cloneRepo", () => {
240241
expect.any(String),
241242
expect.arrayContaining(["--filter=blob:none", "--sparse", "--no-checkout"])
242243
);
244+
expect(mockGitInstance.raw).toHaveBeenCalledWith(["config", "gc.auto", "0"]);
243245
expect(mockGitInstance.fetch).toHaveBeenCalledWith(["origin", "abc123def"]);
244246
expect(mockGitInstance.checkout).toHaveBeenCalledWith("abc123def");
245247
});
@@ -256,6 +258,7 @@ describe("cloneRepo", () => {
256258
expect.any(String),
257259
expect.arrayContaining(["--filter=blob:none", "--sparse", "--depth=1", "-b", "master"])
258260
);
261+
expect(mockGitInstance.raw).toHaveBeenCalledWith(["config", "gc.auto", "0"]);
259262
});
260263

261264
it("non-sparse + tag: clones without sparse-checkout", async () => {

0 commit comments

Comments
 (0)