Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Link to pull requests in changelog notes (#15996)

Joseph T. Lyonsb28507d2e011
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
index ecfc7a9ab81..bf1667643ed 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 a978b8977c4..110a630d1f7 100644
--- a/script/danger/dangerfile.ts
+++ b/script/danger/dangerfile.ts
@@ -21,7 +21,7 @@ if (!hasReleaseNotes) {
"```",
"Release Notes:",
"",
- "- (Added|Fixed|Improved) ... ([#<public_issue_number_if_exists>](https://github.com/zed-industries/zed/issues/<public_issue_number_if_exists>)).",
+ "- 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 c1fefad37f6..6dfc6061beb 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,49 +49,57 @@ 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);
- }
- releaseNotes = notes.trim().split("\n");
- console.log(" Release Notes:");
+ let credit = getCreditString(pullRequestNumber, contributor);
- 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) {