From 2a7bfadd726072a73b688cd3f4c6d72734f16d58 Mon Sep 17 00:00:00 2001 From: Suzumiya Date: Sat, 12 Sep 2026 00:43:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=20CI=EF=BC=9Agit-hooks=20=E5=9B=9E?= =?UTF-8?q?=E5=BD=92=E7=94=A8=E4=BE=8B=E8=B7=9F=E4=B8=8A=20lint-staged=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=9A=84=20*.rs=20=E5=AE=88=E5=8D=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - scripts/git-hooks.test.mjs 用 assert.deepEqual 钉住 package.json 的 lint-staged 整份配置形状,dd7cf401a 新增 *.rs 键时漏了同步,Repository checks(经 npm run lint → check:git-hooks)deepStrictEqual 失败 - 按新形态补上 '*.rs': ['node scripts/lint-staged-rustfmt.mjs'],不放宽断言:仍是整份配置的 deepStrictEqual,改回「只要含 js 那条就算过」这类弱化写法一律不做 - 第 2 个用例里的本地 lintStagedConfig 是 temp repo 的测试替身,不是对真实配置的期望:temp repo 里没有 Rust 文件,加 *.rs 只会命中 0 个文件,故不动 - 变异验证:把 *.rs 从 package.json 摘掉 → 本用例以同样的 deepStrictEqual operator 变红(# fail 2);还原(package.json 字节级哈希一致)后复跑该用例回到 ok --- scripts/git-hooks.test.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/git-hooks.test.mjs b/scripts/git-hooks.test.mjs index 16c0af7de..d140f87d7 100644 --- a/scripts/git-hooks.test.mjs +++ b/scripts/git-hooks.test.mjs @@ -27,6 +27,7 @@ test('pre-commit hook fixes staged imports and formatting without swallowing uns 'node scripts/lint-staged-eslint.mjs', 'prettier --write', ], + '*.rs': ['node scripts/lint-staged-rustfmt.mjs'], }); assert.equal( readFileSync(join(repoRoot, '.husky', 'pre-commit'), 'utf8'),