diff --git a/.github/scripts/pr-carry-attribution.cjs b/.github/scripts/pr-carry-attribution.cjs index 9e0ad1cabc..2886449102 100644 --- a/.github/scripts/pr-carry-attribution.cjs +++ b/.github/scripts/pr-carry-attribution.cjs @@ -56,7 +56,23 @@ const TRAILER_RE = /^[ \t]*co-authored-by:[ \t]*(.+)$/gim; const FENCED_CODE_RE = /^[ \t]*(\u0060{3,}|~{3,})[\s\S]*?^[ \t]*\1[ \t]*$/gm; const INLINE_CODE_RE = /\u0060[^\u0060\n]*\u0060/g; -const HTML_COMMENT_RE = //g; +/** + * HTML comments, which GitHub never renders. + * + * The `(?:-->|$)` alternative is load-bearing and matches `pr-quality.cjs`: an + * UNCLOSED comment runs to the end of the text, because that is what GitHub + * does with it. Without the alternative, `|$)/g; /** * Carry language inside a fenced block, an inline span, or an HTML comment is diff --git a/.github/scripts/pr-carry-attribution.test.cjs b/.github/scripts/pr-carry-attribution.test.cjs index 187469071e..08010a18d2 100644 --- a/.github/scripts/pr-carry-attribution.test.cjs +++ b/.github/scripts/pr-carry-attribution.test.cjs @@ -120,6 +120,35 @@ describe("assessCarryAttribution", () => { ); }); + it("ignores carry language after an unclosed HTML comment", () => { + // GitHub renders nothing after an unterminated ``, and a real claim after it + // is still a claim. + assert.equal( + assessCarryAttribution( + base({ + body: ["", "", "Supersedes #2797."].join("\n"), + }), + ).length, + 1, + ); + }); + it("passes an ordinary pull request with no carry language", () => { assert.deepEqual( assessCarryAttribution(base({ body: "Closes #2797." })),