diff --git a/.github/scripts/tests/verify-release-notes.spec.mjs b/.github/scripts/tests/verify-release-notes.spec.mjs index e3fd409..e13fb0e 100644 --- a/.github/scripts/tests/verify-release-notes.spec.mjs +++ b/.github/scripts/tests/verify-release-notes.spec.mjs @@ -478,7 +478,7 @@ test("labels, description, author and base come from the pull request as it is n fails("## Overview\n", ["Heading not allowed", "No release notes"], { labels: ["minor"], live }); }); -test("a (#n) inside an HTML comment still closes the issue, so it fails; comments stay ignored for everything else", () => { +test("a (#n) inside an HTML comment closes nothing, so it fails; comments stay ignored for everything else", () => { for (const body of [ "\n\n## Added\n\n- A thing (#1)\n", "## Added\n\n- A thing (#1) \n", @@ -487,7 +487,7 @@ test("a (#n) inside an HTML comment still closes the issue, so it fails; comment "## Added\n\n- A thing (#1) \r\n", ]) { const result = fails(body, ["Issue reference position"]); - assert.match(result.errors[0].message, /sits inside an HTML comment.*release-action still closes #\d+.*never put issue references in comments/); + assert.match(result.errors[0].message, /sits inside an HTML comment: release-action removes the comment with it, so #\d+ is not closed.*end of the delivering bullet.*never put issue references in comments/); } // Only fenced and inline code hide a reference, as in release-action, and what surrounds removed code joins up. passes("## Added\n\n- A thing (#1)\n\n```\n\n```\n- Another `` (#2)\n"); diff --git a/.github/workflows/verify-pull-request-policy.yml b/.github/workflows/verify-pull-request-policy.yml index 1a6c6f8..8baeebf 100644 --- a/.github/workflows/verify-pull-request-policy.yml +++ b/.github/workflows/verify-pull-request-policy.yml @@ -158,7 +158,8 @@ jobs: const KEYWORD = /\b(close[sd]?|fix(?:e[sd])?|resolve[sd]?|refs?|references)(?:[ \t]*:[ \t]*|[ \t]+)((?:[\w.-]+\/[\w.-]+)?#(\d+))/gi; const KEYWORD_URL = /\b(close[sd]?|fix(?:e[sd])?|resolve[sd]?|refs?|references)(?:[ \t]*:[ \t]*|[ \t]+)(https?:\/\/(?:www\.)?github\.com\/([\w.-]+\/[\w.-]+)\/(?:issues|pull)\/(\d+))/gi; // The pattern release-action closes issues with. - // It sees everything but fenced and inline code: HTML comments are not skipped. + // release-action removes closed HTML comments first; this check still reads them, so the position + // rule can fail a `(#n)` hidden in one. const CLOSES_ISSUE = /(?` and sentence @@ -462,9 +463,10 @@ jobs: // The same without fenced code, which does not belong to the bullet text around it. const uncommented = blank(blank(text, FENCED_CODE, " "), INLINE_CODE, "x"); const prose = blank(uncommented, HTML_COMMENT, " ").split("\n"); - // What release-action reads when it closes issues: it removes fenced and inline code, in that order, - // and nothing else, so a `(#n)` hidden in an HTML comment still closes its issue. Each match is - // mapped back to where it sits in the description. + // Every `(#n)` outside fenced and inline code, in that order, including those in HTML comments. + // release-action also removes closed comments, so a `(#n)` hidden in one closes nothing; it is + // collected here so the position rule can fail it. Each match is mapped back to where it sits in + // the description. const closes = closingReferences(text, prose); const violations = []; @@ -650,7 +652,7 @@ jobs: } for (const match of closes.filter(candidate => candidate.line === index)) { if (match.commented) { - report("Issue reference position", index, `\`(#${match.number})\` sits inside an HTML comment: the release page does not show the comment, but release-action still closes #${match.number}. Delete it from the comment, or write \`(part of #${match.number})\` or \`see #${match.number}\` outside the comment if it must stay open; never put issue references in comments.`); + report("Issue reference position", index, `\`(#${match.number})\` sits inside an HTML comment: release-action removes the comment with it, so #${match.number} is not closed. Write \`(#${match.number})\` at the end of the delivering bullet, outside the comment, or write \`(part of #${match.number})\` or \`see #${match.number}\` outside the comment if it must stay open; never put issue references in comments.`); continue; } const end = bulletEnd[match.endLine]; diff --git a/.github/workflows/verify-release-notes.yml b/.github/workflows/verify-release-notes.yml index 2053802..e210906 100644 --- a/.github/workflows/verify-release-notes.yml +++ b/.github/workflows/verify-release-notes.yml @@ -67,8 +67,10 @@ name: Verify Release Notes # Fenced and inline code are exempt: release-action ignores them when closing # issues and the release page shows them as code. Closed HTML comments are not # shown on the release page, so the heading, keyword, link and placeholder rules -# ignore them; release-action does NOT ignore them, so a `(#n)` inside a comment -# still closes the issue and fails the position rule. An unclosed `