diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index ecfc7a9ab8..bf1667643e 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,13 +1,15 @@ - +Closes #ISSUE Release Notes: -- Added/Fixed/Improved ... ([#NNNNN](https://github.com/zed-industries/zed/issues/NNNNN)). +- Added/Fixed/Improved ... Optionally, include screenshots / media showcasing your addition that can be included in the release notes. ### Or... +Closes #ISSUE + Release Notes: - N/A diff --git a/script/danger/dangerfile.ts b/script/danger/dangerfile.ts index a978b8977c..110a630d1f 100644 --- a/script/danger/dangerfile.ts +++ b/script/danger/dangerfile.ts @@ -21,7 +21,7 @@ if (!hasReleaseNotes) { "```", "Release Notes:", "", - "- (Added|Fixed|Improved) ... ([#](https://github.com/zed-industries/zed/issues/)).", + "- Added/Fixed/Improved ...", "```", "", 'If your change is not user-facing, you can use "N/A" for the entry:', @@ -33,22 +33,3 @@ 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"), - ); -} diff --git a/script/get-preview-channel-changes b/script/get-preview-channel-changes index c1fefad37f..6dfc6061be 100755 --- a/script/get-preview-channel-changes +++ b/script/get-preview-channel-changes @@ -2,7 +2,12 @@ const { execFileSync } = require("child_process"); let { GITHUB_ACCESS_TOKEN } = process.env; -const FIXES_REGEX = /(fixes|closes|completes) (.+[/#]\d+.*)$/im; +const GITHUB_URL = "https://github.com"; +const SKIPPABLE_NOTE_REGEX = /^\s*-?\s*n\/?a\s*/ims; +const PULL_REQUEST_WEB_URL = "https://github.com/zed-industries/zed/pull"; +const PULL_REQUEST_API_URL = + "https://api.github.com/repos/zed-industries/zed/pulls"; +const DIVIDER = "-".repeat(80); main(); @@ -44,51 +49,59 @@ async function main() { // Fetch the pull requests from the GitHub API. console.log("Merged Pull requests:"); + console.log(DIVIDER); for (const pullRequestNumber of newPullRequestNumbers) { - const webURL = `https://github.com/zed-industries/zed/pull/${pullRequestNumber}`; - const apiURL = `https://api.github.com/repos/zed-industries/zed/pulls/${pullRequestNumber}`; + const pullRequestApiURL = `${PULL_REQUEST_API_URL}/${pullRequestNumber}`; - const response = await fetch(apiURL, { + const response = await fetch(pullRequestApiURL, { headers: { Authorization: `token ${GITHUB_ACCESS_TOKEN}`, }, }); - // Print the pull request title and URL. const pullRequest = await response.json(); const releaseNotesHeader = /^\s*Release Notes:(.+)/ims; let releaseNotes = pullRequest.body || ""; - let contributor = pullRequest.user?.login ?? "Unable to identify"; + let contributor = + pullRequest.user?.login ?? "Unable to identify contributor"; const captures = releaseNotesHeader.exec(releaseNotes); - const notes = captures ? captures[1] : "MISSING"; - const skippableNoteRegex = /^\s*-?\s*n\/?a\s*/ims; + let notes = captures ? captures[1] : "MISSING"; + notes = notes.trim(); - if (skippableNoteRegex.exec(notes) != null) { + if (SKIPPABLE_NOTE_REGEX.exec(notes) != null) { continue; } - console.log("*", pullRequest.title); - console.log(" PR URL: ", webURL); - console.log(" Author: ", contributor); - // If the pull request contains a 'closes' line, print the closed issue. - const fixesMatch = (pullRequest.body || "").match(FIXES_REGEX); - if (fixesMatch) { - const fixedIssueURL = fixesMatch[2]; - console.log(" Issue URL: ", fixedIssueURL); - } + let credit = getCreditString(pullRequestNumber, contributor); - releaseNotes = notes.trim().split("\n"); - console.log(" Release Notes:"); - - for (const line of releaseNotes) { - console.log(` ${line}`); - } + console.log(`PR Title: ${pullRequest.title}`); + console.log(`Credit: (${credit})`); + console.log("Release Notes:"); console.log(); + console.log(notes); + + console.log(DIVIDER); } } +function getCreditString(pullRequestNumber, contributor) { + let credit = ""; + + if (pullRequestNumber) { + let pullRequestMarkdownLink = `[#${pullRequestNumber}](${PULL_REQUEST_WEB_URL}/${pullRequestNumber})`; + credit += pullRequestMarkdownLink; + } + + if (contributor) { + const contributorMarkdownLink = `[${contributor}](${GITHUB_URL}/${contributor})`; + credit += `; thanks ${contributorMarkdownLink}`; + } + + return credit; +} + function getPullRequestNumbers(oldTag, newTag) { const pullRequestNumbers = execFileSync( "git",