Fix(hooks): resolve Windows Bash hook runner (#3397)

* fix: resolve windows bash hook runner

* chore: add changeset for codex bash hooks

* fix: avoid hardcoded windows bash paths

* fix: skip unavailable bash hook registrations
This commit is contained in:
Tom Boucher
2026-05-11 15:32:21 -04:00
committed by GitHub
parent 1f99085559
commit 656fb5868c
3 changed files with 69 additions and 16 deletions

View File

@@ -129,6 +129,27 @@ describe('Bug #2979: buildHookCommand for .sh hooks still uses bare "bash" (POSI
const parsed = parseHookCommand(cmd);
assert.equal(parsed.runner, 'bash');
});
test('Windows .sh hook uses resolved Git Bash path instead of bare bash (#3393)', () => {
const cmd = buildHookCommand('C:/Users/me/.codex', 'gsd-validate-commit.sh', {
platform: 'win32',
env: { ProgramFiles: 'C:\\Program Files' },
existsSync: (candidate) => candidate === 'C:\\Program Files\\Git\\bin\\bash.exe',
});
assert.equal(
cmd,
'& "C:/Program Files/Git/bin/bash.exe" "C:/Users/me/.codex/hooks/gsd-validate-commit.sh"',
);
});
test('Windows .sh hook returns null when no supported Bash runner is found (#3393)', () => {
const cmd = buildHookCommand('C:/Users/me/.codex', 'gsd-phase-boundary.sh', {
platform: 'win32',
env: {},
existsSync: () => false,
});
assert.equal(cmd, null);
});
});
// ─── #3002 CR follow-up: legacy-bare-node migration ─────────────────────────