修复 hook 隔离用例把探针自身的索引写入当成被测行为
Project CI / AI game creator shell Rust smoke (pull_request) Successful in 1m9s
Project CI / Backend tests (pull_request) Failing after 14s
Project CI / AI game creator shell Rust crates (pull_request) Successful in 1m7s
Project CI / Frontend tests (pull_request) Successful in 2m0s
Project CI / Repository checks (pull_request) Failing after 15s
Project CI / AI game creator shell web tests (pull_request) Successful in 1m41s
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Successful in 9m40s
Project CI / Native shell tests (pull_request) Successful in 5m26s
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Successful in 8m45s

- git-hooks.test.mjs 的隔离用例改为先跑会写索引的探针(git status 会刷新并重写索引的 stat 缓存),再取索引快照,避免把自身副作用断言成 hook fixture 的污染
- 该用例在 macOS 与部分 git 版本上必然失败(干净 origin/master worktree 上同样复现),修后 scripts/git-hooks.test.mjs 4/4 通过、npm run check:repository-ci 全绿
This commit is contained in:
2026-09-27 23:01:33 +08:00
parent 6ed1fd26ed
commit 89a51cfd5b
+3 -1
View File
@@ -277,11 +277,13 @@ test('hook fixtures do not mutate the calling linked worktree or its index', ()
writeFileSync(join(worktree, 'sentinel.txt'), 'unstaged\n');
const gitDir = git(worktree, 'rev-parse', '--absolute-git-dir').trim();
const indexPath = join(gitDir, 'index');
// `git status` 会刷新并重写索引里的 stat 缓存(macOS 与部分 git 版本上字节必然变化),
// 所以先跑完会写索引的探针再取快照,否则断言的是探针自身的副作用而不是被测行为。
const before = {
refs: git(outerRepo, 'show-ref'),
config: readFileSync(join(outerRepo, '.git', 'config'), 'utf8'),
index: readFileSync(indexPath),
status: git(worktree, 'status', '--porcelain'),
index: readFileSync(indexPath),
};
const result = spawnSync(
process.execPath,