From 7c024864b2e3c2d469a26e441cadc7943ae549a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Astori?= Date: Wed, 30 Jan 2019 00:37:06 -0500 Subject: [PATCH] Improve discriminating bots from actual contributors in the list of PRs/commits --- scripts/changelog.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/changelog.js b/scripts/changelog.js index 0bfba744..00fbadfc 100644 --- a/scripts/changelog.js +++ b/scripts/changelog.js @@ -299,8 +299,6 @@ class RepositoryFetcher { const commits = await fetchPaginatedCommits(); commits.forEach((commit) => { - commit.author = commit.author.user; - const resultPR = /^Merge pull request #([0-9]+) .+/.exec(commit.messageHeadline); if (resultPR) { @@ -383,6 +381,7 @@ class RepositoryFetcher { title url author { + __typename login url } @@ -482,7 +481,7 @@ function printPullRequest(pullRequest) { // Builds a Markdown list item for a commit made directly in `master` function printCommit(commit) { - return `- ${commit.messageHeadline} (${printEntryLink(commit)} ${printAuthorLink(commit.author)})`; + return `- ${commit.messageHeadline} (${printEntryLink(commit)} ${printAuthorLink(commit.author.user)})`; } // Builds a Markdown list of all given items @@ -690,9 +689,13 @@ function dedupeEntries(changelog, items) { // Given a list of entries (pull requests, commits), retrieves GitHub usernames // (with format `@username`) of everyone who contributed to this version. function extractContributors(entries) { - const set = Object.values(entries).reduce((memo, pullRequest) => { - if (pullRequest.author.login !== "renovate") { - memo.add("@" + pullRequest.author.login); + const set = Object.values(entries).reduce((memo, {__typename, author}) => { + if (__typename === "PullRequest" && author.__typename !== "Bot") { + memo.add("@" + author.login); + // 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. + } else if (__typename === "Commit" && !author.user.login.endsWith("-bot")) { + memo.add("@" + author.user.login); } return memo;