Skip to content

Commit

Permalink
Fix isStaff boolean logic
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephTLyons committed Aug 8, 2024
1 parent abb6d40 commit 5b8ce91
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions script/get-preview-channel-changes
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node --redirect-warnings=/dev/null

const { execFileSync } = require("child_process");
let { GITHUB_ACCESS_TOKEN } = process.env;
const { GITHUB_ACCESS_TOKEN } = process.env;
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";
Expand All @@ -13,10 +13,10 @@ const DIVIDER = "-".repeat(80);
const STAFF_MEMBERS = new Set([
"as-cii",
"bennetbo",
"ConradIrwin",
"danilobleal",
"conradirwin",
"danilo-leal",
"iamnbutler",
"JosephTLyons",
"josephtlyons",
"jvmncs",
"maxbrunsfeld",
"maxdeviant",
Expand All @@ -26,7 +26,7 @@ const STAFF_MEMBERS = new Set([
"osiewicz",
"rgbkrk",
"rtfeldman",
"SomeoneToIgnore",
"someonetoignore",
"thorstenball",
]);

Expand Down Expand Up @@ -83,19 +83,19 @@ async function main() {
const pullRequest = await response.json();
const releaseNotesHeader = /^\s*Release Notes:(.+)/ims;

let releaseNotes = pullRequest.body || "";
const releaseNotes = pullRequest.body || "";
let contributor =
pullRequest.user?.login ?? "Unable to identify contributor";
const captures = releaseNotesHeader.exec(releaseNotes);
let notes = captures ? captures[1] : "MISSING";
notes = notes.trim();
const isStaff = isStaffMember(contributor);

if (SKIPPABLE_NOTE_REGEX.exec(notes) != null) {
continue;
}

let credit = getCreditString(pullRequestNumber, contributor);
const isStaff = STAFF_MEMBERS.has(contributor);
const credit = getCreditString(pullRequestNumber, contributor, isStaff);
contributor = isStaff ? `${contributor} (staff)` : contributor;

console.log(`PR Title: ${pullRequest.title}`);
Expand All @@ -110,15 +110,15 @@ async function main() {
}
}

function getCreditString(pullRequestNumber, contributor) {
function getCreditString(pullRequestNumber, contributor, isStaff) {
let credit = "";

if (pullRequestNumber) {
let pullRequestMarkdownLink = `[#${pullRequestNumber}](${PULL_REQUEST_WEB_URL}/${pullRequestNumber})`;
const pullRequestMarkdownLink = `[#${pullRequestNumber}](${PULL_REQUEST_WEB_URL}/${pullRequestNumber})`;
credit += pullRequestMarkdownLink;
}

if (contributor && !STAFF_MEMBERS.has(contributor)) {
if (contributor && isStaff) {
const contributorMarkdownLink = `[${contributor}](${GITHUB_URL}/${contributor})`;
credit += `; thanks ${contributorMarkdownLink}`;
}
Expand All @@ -142,3 +142,8 @@ function getPullRequestNumbers(oldTag, newTag) {

return pullRequestNumbers;
}

function isStaffMember(githubHandle) {
githubHandle = githubHandle.toLowerCase();
return STAFF_MEMBERS.has(githubHandle);
}

0 comments on commit 5b8ce91

Please sign in to comment.