Skip to content

Commit 7355ff6

Browse files
committed
fix(ci): accept spaced PR evidence sections
Change-Id: I8a21b384a5d0a18f8069becce1464cefaa1250ae
1 parent 01cb843 commit 7355ff6

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

scripts/pr-evidence.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,21 @@ describe("pull-request maintainer evidence", () => {
1818
Add a provider capability.
1919
2020
## Behavior / risk
21+
2122
Existing provider configuration remains unchanged; the new capability is opt-in.
2223
2324
## Validation
25+
2426
\`bun test packages/sdk/tests/unit/provider-conformance.test.ts\``;
2527
expect(validateMaintainerEvidence(body, [".github/workflows/release.yml"])).toBeUndefined();
2628
});
29+
30+
test("does not treat HTML comments as evidence", () => {
31+
const body = `## Behavior / risk
32+
<!--
33+
34+
## Validation
35+
<!--`;
36+
expect(validateMaintainerEvidence(body, [".github/workflows/release.yml"])).toContain("## Behavior / risk");
37+
});
2738
});

scripts/pr-evidence.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ export function requiresMaintainerEvidence(files: readonly string[]): boolean {
1313

1414
function sectionHasContent(body: string, heading: string): boolean {
1515
const escapedHeading = heading.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
16-
const match = body.match(new RegExp(`^## ${escapedHeading}[ \\t]*\\r?\\n([\\s\\S]*?)(?=^## |$)`, "mi"));
16+
const match = body.match(new RegExp(`^## ${escapedHeading}[ \\t]*\\r?\\n([\\s\\S]*?)(?=^## |(?![\\s\\S]))`, "mi"));
1717
if (!match) return false;
1818
return (
1919
match[1]
20-
.replace(/<!--[\s\S]*?-->/g, "")
20+
.replace(/<!--[\s\S]*?(?:-->|$)/g, "")
2121
.replace(/- \[ \] .*/g, "")
2222
.trim().length > 0
2323
);

0 commit comments

Comments
 (0)