Skip to content
Merged
Changes from all 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
17 changes: 13 additions & 4 deletions lib/git-hooks/install.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}) {
Expand Down
Loading