2022-07-09 01:51:28 +03:00
|
|
|
#!/usr/bin/env node --redirect-warnings=/dev/null
|
|
|
|
|
|
|
|
const { execFileSync } = require("child_process");
|
2024-03-21 06:44:12 +03:00
|
|
|
let { GITHUB_ACCESS_TOKEN } = process.env;
|
2023-05-22 06:38:01 +03:00
|
|
|
const FIXES_REGEX = /(fixes|closes|completes) (.+[/#]\d+.*)$/im;
|
2022-07-09 01:51:28 +03:00
|
|
|
|
|
|
|
main();
|
|
|
|
|
|
|
|
async function main() {
|
2022-11-02 20:55:48 +03:00
|
|
|
// Get the last two preview tags
|
2022-07-09 01:51:28 +03:00
|
|
|
const [newTag, oldTag] = execFileSync(
|
|
|
|
"git",
|
|
|
|
["tag", "--sort", "-committerdate"],
|
2023-11-08 19:40:53 +03:00
|
|
|
{ encoding: "utf8" },
|
2022-07-09 01:51:28 +03:00
|
|
|
)
|
|
|
|
.split("\n")
|
2023-05-22 06:38:01 +03:00
|
|
|
.filter((t) => t.startsWith("v") && t.endsWith("-pre"));
|
2022-07-09 01:51:28 +03:00
|
|
|
|
|
|
|
// Print the previous release
|
|
|
|
console.log(`Changes from ${oldTag} to ${newTag}\n`);
|
|
|
|
|
2024-03-21 06:44:12 +03:00
|
|
|
if (!GITHUB_ACCESS_TOKEN) {
|
|
|
|
try {
|
|
|
|
GITHUB_ACCESS_TOKEN = execFileSync("gh", ["auth", "token"]).toString();
|
|
|
|
} catch (error) {
|
|
|
|
console.log(error);
|
|
|
|
console.log("No GITHUB_ACCESS_TOKEN, and no `gh auth token`");
|
|
|
|
process.exit(1);
|
|
|
|
}
|
2022-07-09 01:51:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get the PRs merged between those two tags.
|
2023-05-22 07:02:19 +03:00
|
|
|
const pullRequestNumbers = getPullRequestNumbers(oldTag, newTag);
|
2022-07-09 01:51:28 +03:00
|
|
|
|
2022-11-02 20:55:48 +03:00
|
|
|
// Get the PRs that were cherry-picked between main and the old tag.
|
2023-11-08 19:40:53 +03:00
|
|
|
const existingPullRequestNumbers = new Set(
|
|
|
|
getPullRequestNumbers("main", oldTag),
|
|
|
|
);
|
2023-05-22 06:38:01 +03:00
|
|
|
|
2022-11-02 20:55:48 +03:00
|
|
|
// Filter out those existing PRs from the set of new PRs.
|
2023-11-08 19:40:53 +03:00
|
|
|
const newPullRequestNumbers = pullRequestNumbers.filter(
|
|
|
|
(number) => !existingPullRequestNumbers.has(number),
|
|
|
|
);
|
2022-11-02 20:55:48 +03:00
|
|
|
|
2022-07-09 01:51:28 +03:00
|
|
|
// Fetch the pull requests from the GitHub API.
|
2023-05-22 07:02:19 +03:00
|
|
|
console.log("Merged Pull requests:");
|
2022-11-02 20:55:48 +03:00
|
|
|
for (const pullRequestNumber of newPullRequestNumbers) {
|
2022-07-09 01:51:28 +03:00
|
|
|
const webURL = `https://github.com/zed-industries/zed/pull/${pullRequestNumber}`;
|
|
|
|
const apiURL = `https://api.github.com/repos/zed-industries/zed/pulls/${pullRequestNumber}`;
|
|
|
|
|
|
|
|
const response = await fetch(apiURL, {
|
|
|
|
headers: {
|
|
|
|
Authorization: `token ${GITHUB_ACCESS_TOKEN}`,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
// Print the pull request title and URL.
|
|
|
|
const pullRequest = await response.json();
|
2024-03-21 06:44:12 +03:00
|
|
|
const releaseNotesHeader = /^\s*Release Notes:(.+)/ims;
|
2023-11-08 19:40:53 +03:00
|
|
|
|
|
|
|
let releaseNotes = pullRequest.body || "";
|
2024-07-17 20:20:19 +03:00
|
|
|
let contributor = pullRequest.user.login || "";
|
2023-11-08 19:40:53 +03:00
|
|
|
const captures = releaseNotesHeader.exec(releaseNotes);
|
|
|
|
const notes = captures ? captures[1] : "MISSING";
|
|
|
|
const skippableNoteRegex = /^\s*-?\s*n\/?a\s*/ims;
|
|
|
|
|
|
|
|
if (skippableNoteRegex.exec(notes) != null) {
|
|
|
|
continue;
|
|
|
|
}
|
2022-07-09 01:51:28 +03:00
|
|
|
console.log("*", pullRequest.title);
|
2023-05-22 07:02:19 +03:00
|
|
|
console.log(" PR URL: ", webURL);
|
2024-07-17 20:20:19 +03:00
|
|
|
console.log(" Author: ", contributor);
|
2022-07-09 01:51:28 +03:00
|
|
|
|
|
|
|
// If the pull request contains a 'closes' line, print the closed issue.
|
2023-05-22 06:38:01 +03:00
|
|
|
const fixesMatch = (pullRequest.body || "").match(FIXES_REGEX);
|
2022-07-09 01:51:28 +03:00
|
|
|
if (fixesMatch) {
|
|
|
|
const fixedIssueURL = fixesMatch[2];
|
2023-05-22 07:02:19 +03:00
|
|
|
console.log(" Issue URL: ", fixedIssueURL);
|
2022-07-09 01:51:28 +03:00
|
|
|
}
|
2023-05-22 06:38:01 +03:00
|
|
|
|
2023-11-08 19:40:53 +03:00
|
|
|
releaseNotes = notes.trim().split("\n");
|
|
|
|
console.log(" Release Notes:");
|
2023-05-22 21:44:05 +03:00
|
|
|
|
2023-11-08 19:40:53 +03:00
|
|
|
for (const line of releaseNotes) {
|
|
|
|
console.log(` ${line}`);
|
2023-05-22 06:38:01 +03:00
|
|
|
}
|
2023-05-22 07:02:19 +03:00
|
|
|
|
2023-11-08 19:40:53 +03:00
|
|
|
console.log();
|
2022-07-09 01:51:28 +03:00
|
|
|
}
|
|
|
|
}
|
2023-05-22 06:38:01 +03:00
|
|
|
|
|
|
|
function getPullRequestNumbers(oldTag, newTag) {
|
|
|
|
const pullRequestNumbers = execFileSync(
|
|
|
|
"git",
|
2023-11-08 19:40:53 +03:00
|
|
|
["log", `${oldTag}..${newTag}`, "--oneline"],
|
|
|
|
{ encoding: "utf8" },
|
2023-05-22 06:38:01 +03:00
|
|
|
)
|
|
|
|
.split("\n")
|
2023-11-08 19:40:53 +03:00
|
|
|
.filter((line) => line.length > 0)
|
|
|
|
.map((line) => {
|
2023-05-22 06:38:01 +03:00
|
|
|
const match = line.match(/#(\d+)/);
|
|
|
|
return match ? match[1] : null;
|
|
|
|
})
|
2023-11-08 19:40:53 +03:00
|
|
|
.filter((line) => line);
|
2023-05-22 06:38:01 +03:00
|
|
|
|
2023-05-22 07:02:19 +03:00
|
|
|
return pullRequestNumbers;
|
2023-05-22 06:38:01 +03:00
|
|
|
}
|