修复 hook 隔离用例把探针自身写入当成被测行为 #523
Reference in New Issue
Block a user
Delete Branch "fix/git-hooks-index-snapshot"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
问题
npm run check:repository-ci在scripts/git-hooks.test.mjs:246「hook fixtures do not mutate the calling linked worktree or its index」稳定失败;在干净的origin/master独立 worktree 上同样复现,属既有问题。根因
用例在调用
git status --porcelain之前读取索引做快照,而git status会刷新并重写索引里的 stat 缓存(macOS 与部分 git 版本上字节必然变化),于是断言到的是探针自身的副作用,而不是 hook fixture 的污染。修复
node --test scripts/git-hooks.test.mjs4/4 通过;bash scripts/check-repository-ci.sh origin/master退出码 0(此前同一条用例必失败)。