fix(server): background git status fetches no longer fill the disk with failed repacks (#13812)
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
1 parent
295d7cba09
commit
95030dc674
2 files changed
+34
-1
No files matched your search
@@ -1918,6 +1918,35 @@ it.layer(TestLayer)("GitVcsDriver core integration", (it) => {
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("does not start Git auto-maintenance from background upstream fetches", () =>
|
||||
Effect.gen(function* () {
|
||||
const cwd = yield* makeTmpDir();
|
||||
const remote = yield* makeTmpDir("git-vcs-driver-remote-");
|
||||
const { initialBranch } = yield* initRepoWithCommit(cwd);
|
||||
yield* git(remote, ["init", "--bare"]);
|
||||
yield* git(cwd, ["remote", "add", "origin", remote]);
|
||||
yield* git(cwd, ["push", "-u", "origin", initialBranch]);
|
||||
yield* git(cwd, ["repack", "-d"]);
|
||||
yield* writeTextFile(cwd, "second.txt", "second\n");
|
||||
yield* git(cwd, ["add", "second.txt"]);
|
||||
yield* git(cwd, ["commit", "-m", "second commit"]);
|
||||
yield* git(cwd, ["push"]);
|
||||
yield* git(cwd, ["repack", "-d"]);
|
||||
// Two packs make `git gc --auto` due, and without detaching it would run inside the fetch.
|
||||
yield* git(cwd, ["config", "gc.autoPackLimit", "1"]);
|
||||
yield* git(cwd, ["config", "gc.autoDetach", "false"]);
|
||||
yield* git(cwd, ["config", "maintenance.autoDetach", "false"]);
|
||||
const packCount = git(cwd, ["count-objects", "-v"]).pipe(
|
||||
Effect.map((stdout) => stdout.match(/^packs: (\d+)$/m)?.[1]),
|
||||
);
|
||||
assert.equal(yield* packCount, "2");
|
||||
|
||||
yield* (yield* GitVcsDriver.GitVcsDriver).statusDetailsRemote(cwd);
|
||||
|
||||
assert.equal(yield* packCount, "2");
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("uses origin HEAD for default-branch detection with a non-origin upstream", () =>
|
||||
Effect.gen(function* () {
|
||||
const cwd = yield* makeTmpDir();
|
||||
|
||||
@@ -1127,10 +1127,14 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
|
||||
): Effect.Effect<void, GitCommandError> => {
|
||||
const fetchCwd =
|
||||
path.basename(gitCommonDir) === ".git" ? path.dirname(gitCommonDir) : gitCommonDir;
|
||||
// `--no-auto-gc` (a synonym of `--no-auto-maintenance` that older Git also knows) keeps
|
||||
// this poll from starting `git gc --auto`. When that gc fails, for example on a repository
|
||||
// with missing objects, Git retries it on every fetch and leaves a full-size `tmp_pack_*`
|
||||
// behind each time, so a background poll could fill the disk.
|
||||
return executeGit(
|
||||
"GitVcsDriver.fetchRemoteForStatus",
|
||||
fetchCwd,
|
||||
["--git-dir", gitCommonDir, "fetch", "--quiet", "--no-tags", remoteName],
|
||||
["--git-dir", gitCommonDir, "fetch", "--quiet", "--no-tags", "--no-auto-gc", remoteName],
|
||||
{
|
||||
env: STATUS_UPSTREAM_REFRESH_ENV,
|
||||
fallbackErrorDetail: "Background Git fetch exited with a non-zero status.",
|
||||
|
||||
Reference in new issue
Block a user