From ea6a24b1c1492283777ad4f7f954b0e37339172d Mon Sep 17 00:00:00 2001 From: Kyle Sexton <153232337+kyle-sexton@users.noreply.github.com> Date: Sat, 24 Oct 2026 02:34:21 -0400 Subject: [PATCH] test(git-hooks): stop auto maintenance racing the installer test's tree snapshots A fixture commit can spawn a detached `git maintenance --auto` whose .git/objects/maintenance.lock appears in one tree() read and not the next, failing "plan returns the remotes: entry and lefthook install, and writes nothing" (run 40069911482). Every git the test spawns now runs with maintenance.auto=false and gc.auto=0 through GIT_CONFIG_COUNT. Co-Authored-By: Claude Opus 5.5 --- lib/git-hooks/install.test.mjs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/git-hooks/install.test.mjs b/lib/git-hooks/install.test.mjs index 3b80f722f8f..acfd336a04c 100644 --- a/lib/git-hooks/install.test.mjs +++ b/lib/git-hooks/install.test.mjs @@ -34,13 +34,22 @@ after(() => rmSync(work, { recursive: true, force: true })); const has = (tool) => spawnSync("sh", ["-c", `command -v ${tool}`]).status === 0; const posixHost = process.platform !== "win32"; -// Git sees no global or system config, so a host core.hooksPath cannot leak in. -const baseEnv = { ...process.env, GIT_CONFIG_GLOBAL: path.join(work, "no-global"), GIT_CONFIG_NOSYSTEM: "1" }; +// Git sees no global or system config, so a host core.hooksPath cannot leak in, +// and runs no detached auto maintenance, whose lock file would change a tree() snapshot. +const gitEnv = { + GIT_CONFIG_GLOBAL: path.join(work, "no-global"), + GIT_CONFIG_NOSYSTEM: "1", + GIT_CONFIG_COUNT: "2", + GIT_CONFIG_KEY_0: "maintenance.auto", + GIT_CONFIG_VALUE_0: "false", + GIT_CONFIG_KEY_1: "gc.auto", + GIT_CONFIG_VALUE_1: "0", +}; +const baseEnv = { ...process.env, ...gitEnv }; for (const k of ["GIT_DIR", "GIT_WORK_TREE", "GIT_INDEX_FILE", "CLAUDECODE", "AI_AGENT", "HUSKY", "CLAUDE_PLUGIN_DATA"]) { delete baseEnv[k]; } -process.env.GIT_CONFIG_GLOBAL = baseEnv.GIT_CONFIG_GLOBAL; -process.env.GIT_CONFIG_NOSYSTEM = "1"; +Object.assign(process.env, gitEnv); let counter = 0; function git(repo, args, env = {}) {