mirror of
https://github.com/thelounge/thelounge
synced 2024-11-14 00:07:17 +00:00
changelog: don't break if author is nil
The author field can somehow be null for whatever reason... Guard the script against blowing up
This commit is contained in:
parent
48213955b9
commit
515f894c13
1 changed files with 25 additions and 10 deletions
|
@ -554,9 +554,8 @@ function printPullRequest(pullRequest) {
|
||||||
|
|
||||||
// Builds a Markdown list item for a commit made directly in `master`
|
// Builds a Markdown list item for a commit made directly in `master`
|
||||||
function printCommit(commit) {
|
function printCommit(commit) {
|
||||||
return `- ${commit.messageHeadline} (${printEntryLink(commit)} ${printAuthorLink(
|
const author_link = commit.author.user ? printAuthorLink(commit.author.user) : "unknown author";
|
||||||
commit.author.user
|
return `- ${commit.messageHeadline} (${printEntryLink(commit)} ${author_link})`;
|
||||||
)})`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Builds a Markdown list of all given items
|
// Builds a Markdown list of all given items
|
||||||
|
@ -812,15 +811,31 @@ function dedupeEntries(changelog, items) {
|
||||||
// (with format `@username`) of everyone who contributed to this version.
|
// (with format `@username`) of everyone who contributed to this version.
|
||||||
function extractContributors(entries) {
|
function extractContributors(entries) {
|
||||||
const set = Object.values(entries).reduce((memo, {__typename, author}) => {
|
const set = Object.values(entries).reduce((memo, {__typename, author}) => {
|
||||||
if (__typename === "PullRequest" && author.__typename !== "Bot") {
|
if (!author) {
|
||||||
memo.add("@" + author.login);
|
// author can be null if GH doesn't recognize them
|
||||||
// Commit authors are *always* of type "User", so have to discriminate some
|
return memo;
|
||||||
// other way. Making the assumption of a suffix for now, see how that goes.
|
|
||||||
} else if (__typename === "Commit" && !author.user.login.endsWith("-bot")) {
|
|
||||||
memo.add("@" + author.user.login);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return memo;
|
switch (__typename) {
|
||||||
|
case "PullRequest":
|
||||||
|
if (author.__typename !== "Bot") {
|
||||||
|
memo.add("@" + author.login);
|
||||||
|
}
|
||||||
|
|
||||||
|
return memo;
|
||||||
|
case "Commit":
|
||||||
|
// Commit authors are *always* of type "User", so have to discriminate some
|
||||||
|
// other way. Making the assumption of a suffix for now, see how that goes.
|
||||||
|
// author.user can be nil if GH doesn't recognize the email
|
||||||
|
if (!author.user || author.user.login.endsWith("-bot")) {
|
||||||
|
return memo;
|
||||||
|
}
|
||||||
|
|
||||||
|
memo.add("@" + author.user.login);
|
||||||
|
return memo;
|
||||||
|
default:
|
||||||
|
throw new Error(`got an unexpected type for extractContributors: ${__typename}`);
|
||||||
|
}
|
||||||
}, new Set());
|
}, new Set());
|
||||||
|
|
||||||
return Array.from(set).sort((a, b) => a.localeCompare(b, "en", {sensitivity: "base"}));
|
return Array.from(set).sort((a, b) => a.localeCompare(b, "en", {sensitivity: "base"}));
|
||||||
|
|
Loading…
Reference in a new issue