mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-16 04:45:33 -08:00
Scrub git config for the whole test process in skill-script-helpers, so fixtures, imported modules and spawned scripts always agree
AI Assisted
This commit is contained in:
1 parent
498e09bb15
commit
72c827dddf
2 files changed
+10
-7
No files matched your search
@@ -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_<BRAND>_ENTRIES` constant, a `<brand>Dir` option, a `"<brand>"` 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/<KEY>-${11000 + i}-…` `` template literals, which a digits-only rewrite to `ABC-<n>` 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`).
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user