Fix isStaff boolean logic
This commit is contained in:
parent
abb6d40fbf
commit
5b8ce91048
1 changed files with 16 additions and 11 deletions
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env node --redirect-warnings=/dev/null
|
#!/usr/bin/env node --redirect-warnings=/dev/null
|
||||||
|
|
||||||
const { execFileSync } = require("child_process");
|
const { execFileSync } = require("child_process");
|
||||||
let { GITHUB_ACCESS_TOKEN } = process.env;
|
const { GITHUB_ACCESS_TOKEN } = process.env;
|
||||||
const GITHUB_URL = "https://github.com";
|
const GITHUB_URL = "https://github.com";
|
||||||
const SKIPPABLE_NOTE_REGEX = /^\s*-?\s*n\/?a\s*/ims;
|
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_WEB_URL = "https://github.com/zed-industries/zed/pull";
|
||||||
|
@ -13,10 +13,10 @@ const DIVIDER = "-".repeat(80);
|
||||||
const STAFF_MEMBERS = new Set([
|
const STAFF_MEMBERS = new Set([
|
||||||
"as-cii",
|
"as-cii",
|
||||||
"bennetbo",
|
"bennetbo",
|
||||||
"ConradIrwin",
|
"conradirwin",
|
||||||
"danilobleal",
|
"danilo-leal",
|
||||||
"iamnbutler",
|
"iamnbutler",
|
||||||
"JosephTLyons",
|
"josephtlyons",
|
||||||
"jvmncs",
|
"jvmncs",
|
||||||
"maxbrunsfeld",
|
"maxbrunsfeld",
|
||||||
"maxdeviant",
|
"maxdeviant",
|
||||||
|
@ -26,7 +26,7 @@ const STAFF_MEMBERS = new Set([
|
||||||
"osiewicz",
|
"osiewicz",
|
||||||
"rgbkrk",
|
"rgbkrk",
|
||||||
"rtfeldman",
|
"rtfeldman",
|
||||||
"SomeoneToIgnore",
|
"someonetoignore",
|
||||||
"thorstenball",
|
"thorstenball",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -83,19 +83,19 @@ async function main() {
|
||||||
const pullRequest = await response.json();
|
const pullRequest = await response.json();
|
||||||
const releaseNotesHeader = /^\s*Release Notes:(.+)/ims;
|
const releaseNotesHeader = /^\s*Release Notes:(.+)/ims;
|
||||||
|
|
||||||
let releaseNotes = pullRequest.body || "";
|
const releaseNotes = pullRequest.body || "";
|
||||||
let contributor =
|
let contributor =
|
||||||
pullRequest.user?.login ?? "Unable to identify contributor";
|
pullRequest.user?.login ?? "Unable to identify contributor";
|
||||||
const captures = releaseNotesHeader.exec(releaseNotes);
|
const captures = releaseNotesHeader.exec(releaseNotes);
|
||||||
let notes = captures ? captures[1] : "MISSING";
|
let notes = captures ? captures[1] : "MISSING";
|
||||||
notes = notes.trim();
|
notes = notes.trim();
|
||||||
|
const isStaff = isStaffMember(contributor);
|
||||||
|
|
||||||
if (SKIPPABLE_NOTE_REGEX.exec(notes) != null) {
|
if (SKIPPABLE_NOTE_REGEX.exec(notes) != null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let credit = getCreditString(pullRequestNumber, contributor);
|
const credit = getCreditString(pullRequestNumber, contributor, isStaff);
|
||||||
const isStaff = STAFF_MEMBERS.has(contributor);
|
|
||||||
contributor = isStaff ? `${contributor} (staff)` : contributor;
|
contributor = isStaff ? `${contributor} (staff)` : contributor;
|
||||||
|
|
||||||
console.log(`PR Title: ${pullRequest.title}`);
|
console.log(`PR Title: ${pullRequest.title}`);
|
||||||
|
@ -110,15 +110,15 @@ async function main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCreditString(pullRequestNumber, contributor) {
|
function getCreditString(pullRequestNumber, contributor, isStaff) {
|
||||||
let credit = "";
|
let credit = "";
|
||||||
|
|
||||||
if (pullRequestNumber) {
|
if (pullRequestNumber) {
|
||||||
let pullRequestMarkdownLink = `[#${pullRequestNumber}](${PULL_REQUEST_WEB_URL}/${pullRequestNumber})`;
|
const pullRequestMarkdownLink = `[#${pullRequestNumber}](${PULL_REQUEST_WEB_URL}/${pullRequestNumber})`;
|
||||||
credit += pullRequestMarkdownLink;
|
credit += pullRequestMarkdownLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contributor && !STAFF_MEMBERS.has(contributor)) {
|
if (contributor && isStaff) {
|
||||||
const contributorMarkdownLink = `[${contributor}](${GITHUB_URL}/${contributor})`;
|
const contributorMarkdownLink = `[${contributor}](${GITHUB_URL}/${contributor})`;
|
||||||
credit += `; thanks ${contributorMarkdownLink}`;
|
credit += `; thanks ${contributorMarkdownLink}`;
|
||||||
}
|
}
|
||||||
|
@ -142,3 +142,8 @@ function getPullRequestNumbers(oldTag, newTag) {
|
||||||
|
|
||||||
return pullRequestNumbers;
|
return pullRequestNumbers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isStaffMember(githubHandle) {
|
||||||
|
githubHandle = githubHandle.toLowerCase();
|
||||||
|
return STAFF_MEMBERS.has(githubHandle);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue