From 72c827dddfae58e2de94ca2d429bd9d51bee1a89 Mon Sep 17 00:00:00 2001 From: Justin Parker Date: Wed, 14 Oct 2026 20:30:35 -0700 Subject: [PATCH] Scrub git config for the whole test process in skill-script-helpers, so fixtures, imported modules and spawned scripts always agree AI Assisted --- AGENTS.md | 2 +- scripts/skill-script-helpers.mjs | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index b47892a..3fa75d0 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -98,5 +98,5 @@ When you make a mistake, get corrected, or discover something about this codebas - When a new first-run dialog is added to the web console, set its seen flag in `scripts/capture-screenshots.mjs`'s `looks.json` too: the Welcome dialog once covered the regenerated dashboard screenshots until `welcomeSeen: true` was added. - After a sync, grep for the upstream brand word on its own too, not only the full product name: the rebrand map misses a bare brand word inside identifiers and fixtures (a `KEPT__ENTRIES` constant, a `Dir` option, a `""` test folder, an owner slug in a git remote URL), and v2.7.0's sync let all four through until the residual grep caught them. - After a sync, grep for the upstream ticket key followed by anything, not only by digits: v2.8.0's git board fixtures built branch names as `` `feature/-${11000 + i}-…` `` template literals, which a digits-only rewrite to `ABC-` misses. -- Build test git fixtures with `gitIn` / `scrubbedEnv` from `scripts/skill-script-helpers.mjs`, never with the ambient git config: a global `core.autocrlf=true` checked fixtures out with CRLF that the scrubbed scripts then read as changed, failing `git plan switch` on Windows. +- Import `scripts/skill-script-helpers.mjs` in any test that builds git fixtures for a skill script or `git-repo.mjs`: it scrubs the whole test process's git config, so fixtures, imported modules and spawned scripts agree. Mixed configs broke `git plan switch` once (a global `core.autocrlf=true` checked fixtures out with CRLF the scrubbed script read as changed). - Before deleting a test file that upstream split or removed, diff plan2code's copy against the rebranded upstream base and port the plan2code-only tests: v2.7.0's split of the web console suite would otherwise have dropped seven hardening tests (now in `scripts/test-web-console-hardening.mjs`). diff --git a/scripts/skill-script-helpers.mjs b/scripts/skill-script-helpers.mjs index 2fb3bd8..121fa48 100644 --- a/scripts/skill-script-helpers.mjs +++ b/scripts/skill-script-helpers.mjs @@ -57,6 +57,13 @@ export function scrubbedEnv(extra = {}) { return { ...e, GIT_CONFIG_NOSYSTEM: "1", GIT_CONFIG_GLOBAL: EMPTY_GITCONFIG, ...extra }; } +// Every git in a test process that imports this file runs under that same +// scrubbed config: fixture commands, the modules a test imports and the +// scripts it spawns. Mixed configs disagree: a global core.autocrlf=true once +// checked fixtures out with CRLF that the scrubbed scripts read as changed. +for (const k of AMBIENT_GIT_ENV) delete process.env[k]; +Object.assign(process.env, { GIT_CONFIG_NOSYSTEM: "1", GIT_CONFIG_GLOBAL: EMPTY_GITCONFIG }); + export function runScript(skill, script, args, { cwd, env } = {}) { const r = spawnSync(process.execPath, [path.join(SKILLS, skill, "scripts", script), ...args], { cwd: cwd || ROOT, @@ -83,12 +90,8 @@ export function write(root, rel, content) { export const read = (root, rel) => fs.readFileSync(path.join(root, rel), "utf8"); -/** - * A git runner for `dir`, under the same scrubbed config the scripts get: with - * the ambient config, a global core.autocrlf=true checks files out with CRLF - * that the scripts (autocrlf off) then read as changed. - */ -export const gitIn = (dir) => (...a) => execFileSync("git", a, { cwd: dir, stdio: "pipe", encoding: "utf8", env: scrubbedEnv() }); +/** A git runner for `dir`, under the scrubbed config set beside `scrubbedEnv`. */ +export const gitIn = (dir) => (...a) => execFileSync("git", a, { cwd: dir, stdio: "pipe", encoding: "utf8" }); export function gitInit(dir, branch = "main") { const g = gitIn(dir);