fix(ci): 质量检查 - 处理强制推送后的基准提交缺失

This commit is contained in:
ddcat666 committed 2026-09-26 17:30:17 +08:00
1 parent 331609e6ab
commit 8346865481
2 files changed
+23 -4

No files matched your search

+10 -2
View File
@@ -71,9 +71,17 @@ describe("changed-file formatting gate", () => {
expect(repo.messages).toEqual([]);
});
test("invalid explicit base SHA fails closed", async () => {
test("unavailable explicit base SHA falls back to the head parent", async () => {
const repo = fixture();
await expect(repo.check({ baseSha: "f".repeat(40) })).rejects.toThrow("git rev-parse");
repo.write("changed.ts", "const value=1;\n");
repo.commit();
await expect(repo.check({ baseSha: "f".repeat(40) })).rejects.toThrow("changed.ts");
expect(repo.messages).toContain(`Base SHA ${"f".repeat(40)} is unavailable; checking against the head parent instead.`);
});
test("malformed explicit base SHA fails closed", async () => {
const repo = fixture();
await expect(repo.check({ baseSha: "not-a-sha" })).rejects.toThrow("Invalid base SHA");
});
test("zero before SHA compares the parent commit", async () => {