From 8ef53aafa2d84d1152868ba03d6c1adaecc081ca Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Wed, 17 Jul 2024 17:15:47 -0400 Subject: [PATCH] Have Danger check the format of GitHub issue links (#14684) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR updates the Danger rules to check for GitHub issue links that aren't in the desired format: Screenshot 2024-07-17 at 5 11 48 PM We don't yet check that the links are exactly formatted as expected, just that they aren't incorrectly formatted in the way that people typically get it wrong. Release Notes: - N/A --- script/danger/dangerfile.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/script/danger/dangerfile.ts b/script/danger/dangerfile.ts index ced6e6eef7..a978b8977c 100644 --- a/script/danger/dangerfile.ts +++ b/script/danger/dangerfile.ts @@ -33,3 +33,22 @@ if (!hasReleaseNotes) { ].join("\n"), ); } + +const INCORRECT_ISSUE_LINK_PATTERN = new RegExp("-.*\\(#\\d+\\)", "g"); + +const hasIncorrectIssueLinks = INCORRECT_ISSUE_LINK_PATTERN.test( + danger.github.pr.body, +); +if (hasIncorrectIssueLinks) { + warn( + [ + "This PR has incorrectly formatted GitHub issue links in the release notes.", + "", + "GitHub issue links must be formatted as plain Markdown links:", + "", + "```", + "- Improved something ([#ISSUE](https://github.com/zed-industries/zed/issues/ISSUE)).", + "```", + ].join("\n"), + ); +}