fix(detail-page-structure-progress-actions): 兼容删除文件的环境契约校验

这个提交包含在:
2026-08-03 16:00:49 +08:00
父节点 b7d5761067
当前提交 d5b3ba058c
共修改 2 个文件,包含 12 行新增和 0 行删除
+1
查看文件
@@ -326,6 +326,7 @@ const trackedFiles = childProcess.execFileSync('git', ['ls-files', '--cached', '
const literalWebhookPattern = /https:\/\/qyapi\.weixin\.qq\.com\/cgi-bin\/webhook\/send\?key=/; const literalWebhookPattern = /https:\/\/qyapi\.weixin\.qq\.com\/cgi-bin\/webhook\/send\?key=/;
for (const relativePath of trackedFiles) { for (const relativePath of trackedFiles) {
const filePath = path.join(rootDir, relativePath); const filePath = path.join(rootDir, relativePath);
if (!fs.existsSync(filePath)) continue;
if (!fs.statSync(filePath).isFile()) continue; if (!fs.statSync(filePath).isFile()) continue;
const content = fs.readFileSync(filePath); const content = fs.readFileSync(filePath);
if (content.includes(0)) continue; if (content.includes(0)) continue;
@@ -45,6 +45,17 @@ describe("environment recovery classification contract", () => {
expect(result.stdout).toContain("环境恢复分类键数: 164"); expect(result.stdout).toContain("环境恢复分类键数: 164");
}); });
it("skips tracked paths deleted in the current worktree before reading metadata", async () => {
const source = await readFile(VALIDATOR, "utf8");
const trackedFileLoop = source.indexOf("for (const relativePath of trackedFiles)");
const existsGuard = source.indexOf("if (!fs.existsSync(filePath)) continue;", trackedFileLoop);
const statRead = source.indexOf("fs.statSync(filePath)", trackedFileLoop);
expect(trackedFileLoop).toBeGreaterThanOrEqual(0);
expect(existsGuard).toBeGreaterThan(trackedFileLoop);
expect(statRead).toBeGreaterThan(existsGuard);
});
it("rejects a missing key", async () => { it("rejects a missing key", async () => {
const classification = structuredClone(baseClassification); const classification = structuredClone(baseClassification);
classification.categories.template_rebuild = classification.categories.template_rebuild classification.categories.template_rebuild = classification.categories.template_rebuild