Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions scripts/routine-gate/__tests__/gate-core.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,15 @@ describe("parseClosesIssue / closesIssueRefs hardening", () => {
expect(parseClosesIssue("Closes #42 and again Closes #42")).toBe(42);
expect(closesIssueRefs("Closes #42 Closes #42")).toEqual([42]);
});
it("ignores Closes inside inline code span", () => {
expect(parseClosesIssue("Example: `Closes #999`\n\nCloses #42")).toBe(42);
});
it("ignores Closes inside fenced code block", () => {
expect(parseClosesIssue("```\nCloses #999\n```\n\nCloses #42")).toBe(42);
});
it("ignores Closes inside unterminated HTML comment (strips to end of line)", () => {
expect(parseClosesIssue("<!-- Closes #999\n\nCloses #42")).toBe(42);
});
});

describe("evaluateGate ambiguity + provenance source-of-truth", () => {
Expand Down
7 changes: 5 additions & 2 deletions scripts/routine-gate/gate-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ export interface PrInfo {

type Cfg = typeof CONFIG_T;

// Strip HTML comments and markdown blockquote lines, then collect DISTINCT issue refs.
// Strip code spans, HTML comments, and markdown blockquote lines, then collect DISTINCT issue refs.
export function closesIssueRefs(body: string): number[] {
const cleaned = body
.replace(/<!--[\s\S]*?-->/g, " ") // drop HTML comments
.replace(/```[\s\S]*?```/g, " ") // drop fenced code blocks
.replace(/`[^`\n]+`/g, " ") // drop inline code spans
.replace(/<!--[\s\S]*?-->/g, " ") // drop complete HTML comments
.replace(/<!--[^\n]*/g, " ") // drop unterminated HTML comment starts (to end of line)
.split("\n")
.filter((line) => !/^\s*>/.test(line)) // drop blockquote lines
.join("\n");
Expand Down