Repository navigation
arch-docs: run git without a shell so ^{commit} survives Windows - #1969
Merged
Merged
Conversation
core/scripts/check-arch-docs.mjs built four git commands as strings and ran
them through the shell (execSync). On Windows that shell is cmd.exe, where
`^` escapes the next character, so origin/main^{commit} arrived at git as
origin/main{commit}; rev-parse failed and the gate reported
"cannot diff against origin/main" on a checkout where origin/main existed —
every scheduled windows-latest row failed the Lint step from 2026-10-17 on.
Run git with its arguments as a list (execFileSync) instead, the ref verbatim
as one argument. The fail-closed behaviour on a genuinely missing base ref is
unchanged: core/test/check-arch-docs.test.js keeps "invalid base ref fails
closed" and gains "the gate never runs git through a shell", which fails on
the old source (git started by sh) and passes on this one.
Fixes #1954
…hell line Docs-not-needed: updates the owning page docs/subsystems/install.md itself.
Collaborator
Author
|
Verdict: PASS at c722893 Ran at this tip: Review notes:
|
This was referenced Nov 1, 2026
test: the arch-docs shell-guard case is POSIX-only and will fail the Windows Compatibility job
#1973
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1954
Owner: Chief
Reviewer: Reviewer
Written-by: Claim 2f6d
Branch: dev/1954-arch-docs-gate-no-shell
Base: beba27a
Tip SHA: c722893
Docs-not-needed: no —
docs/subsystems/install.mdownscore/scripts/andcore/test/check-arch-docs.test.js, so its "Key files" row is updated in this tree.The arch-docs gate built four git command lines as strings and ran them through a shell. On Windows that shell is
cmd.exe, where^escapes the next character:git rev-parse --verify origin/main^{commit}reached git asorigin/main{commit}, rev-parse failed, andassertBaseRef's catch reportedcannot diff against origin/mainon a checkout that hadorigin/main(Triage re-read the log:* [new ref] 88aaf3c7… -> origin/mainandgit rev-parse refs/remotes/origin/main→88aaf3c7…in the same job). Every scheduledwindows-latestrow failed its Lint step that way from 2026-10-17 on, whilenpm run lintitself reported 0 errors.The gate now hands git its arguments as a list —
execFileSync('git', ['rev-parse', '--verify',${ref}^{commit}])and the same fordiff --name-only <ref>...HEAD,diff --name-only <ref>...HEAD -- <file>andlog <ref>..HEAD --pretty=%B— so^{commit}is one argv element and no shell interprets it. The ref is still taken fromARCH_DOCS_BASE/origin/mainunchanged and the fail-closed path is untouched: a genuinely missing base ref still throwscannot diff against <ref>.What changed
execSync('git rev-parse --verify ' + ref + '^{commit}')execFileSync('git', ['rev-parse','--verify', ref + '^{commit}'])execSync('git diff --name-only <ref>...HEAD')execFileSync('git', ['diff','--name-only', '<ref>...HEAD'])execSync('git diff --name-only <ref>...HEAD -- <file>')execFileSync('git', ['diff','--name-only', '<ref>...HEAD', '--', file])execSync('git log <ref>..HEAD --pretty=%B')execFileSync('git', ['log', '<ref>..HEAD', '--pretty=%B'])No output format, exit code, message or call site changes;
execSyncis gone from the file and the import is nowexecFileSync.Verification at the tip
Tip SHA: c722893
Ran:
cd core && node --test test/check-arch-docs.test.js→ 7/7 pass (the six existing cases, includinginvalid base ref fails closedandempty diff passes, plus the new one);node scripts/check-arch-docs.mjs→arch-docs: OKexit 0;node scripts/ds-bot-patches.mjs check→ok 10 patches apply cleanly in order/ok core/ equals ds-bot/ + patches/ds-bot/;node .github/scripts/changelog.mjs check→ 6 fragments well formed.The two
patches/ds-bot/files/entries are byte copies of the tipcore/files (both are files upstream ds-bot does not have, sogeneratestores them verbatim); this machine has no git, sogeneratecould not run and the copies were made by hand and then proved bycheckabove.npm run verifywas not run here for the same reason (generate/gitabsent); CI runs it.Not run (and why): the scheduled Compatibility run itself — that needs a dispatch after merge, see
next.Red first
The new case
the gate never runs git through a shellputs a fakegitfirst on PATH in a temp dir. The fake records the name of its parent process and exits non-zero when that parent is a shell (sh/dash/bash/zsh/ksh/cmd*); otherwise it answersrev-parsewith a sha anddiff/logwith nothing. The test then runs the real gate withspawnSync(process.execPath, ['scripts/check-arch-docs.mjs'])and asserts the parent was not a shell and the gate exited 0.Against the base blob (
core/scripts/check-arch-docs.mjsfrombeba27a77e9ca453a1c357fff497c6a500d4be0e, this branch's test file):Against this tip, same command:
# pass 7 / # fail 0. The case pins the class — "git was started by a shell" — not one Windows symptom, so it stays red for any futureexecSyncthat creeps back in.Checkpoint
{ "pr": 1969, "claim": "Chief", "issue": 1954, "summary": "The arch-docs gate ran four git commands through a shell; on Windows cmd.exe ate the ^ in origin/main^{commit}, so rev-parse failed and every scheduled windows-latest row reported cannot diff against origin/main. It now passes git its arguments as a list with the ref verbatim, so no shell interprets ^{commit}. Fail-closed on a genuinely missing base ref is unchanged. install.md records the rule and a new test pins it.", "files": ["core/scripts/check-arch-docs.mjs", "core/test/check-arch-docs.test.js", "patches/ds-bot/files/scripts/check-arch-docs.mjs", "patches/ds-bot/files/test/check-arch-docs.test.js", "docs/subsystems/install.md", "changelog.d/1954-arch-docs-no-shell.fixed.md"], "checks": { "ran": "cd core && node --test test/check-arch-docs.test.js && node scripts/check-arch-docs.mjs; node scripts/ds-bot-patches.mjs check; node .github/scripts/changelog.mjs check", "result": "green", "at": "c722893f6967ec93d42f2623fe8415fb395ae05b" }, "next": "After merge, dispatch nightly.yml on main and confirm the windows-latest · Node 24 row's Lint step is green — that is the only place the cmd.exe path runs." }