test(redact): fixture git and hook installs share gitEnv(), so a global core.hooksPath is never rewritten (#3353)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
garrytanandcapy-ai[bot] committed 2026-10-24 20:18:24 +00:00
1 parent 00100f1598
commit afaa28d677
7 files changed
+124 -72

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
/**
* Environment for fixture git commands and `gstack-redact install-prepush-hook`.
*
* With the parent environment, a developer's global or system core.hooksPath
* (or the same key via GIT_CONFIG_COUNT / GIT_CONFIG_PARAMETERS) reaches the
* fixture: `git rev-parse --git-path hooks` resolves to that directory, so the
* install rewrites the developer's own pre-push (#3353), and their hook runs
* on fixture pushes and rejects the local remote (#2967). /dev/null drops the
* global file on every platform: Git for Windows rejects NUL (see
* EMPTY_GLOBAL_GIT_CONFIG in lib/cso/process.ts). Config written inside the
* fixture repo still applies.
*/
export function gitEnv(extra: Record<string, string | undefined> = {}): NodeJS.ProcessEnv {
const env: NodeJS.ProcessEnv = { ...process.env, ...extra };
env.GIT_CONFIG_GLOBAL = "/dev/null";
env.GIT_CONFIG_NOSYSTEM = "1";
env.GIT_CONFIG_COUNT = "0";
delete env.GIT_CONFIG_PARAMETERS;
return env;
}