Improve discriminating bots from actual contributors in the list of PRs/commits

This commit is contained in:
Jérémie Astori 2019-01-30 00:37:06 -05:00
parent 682207ffe6
commit 7c024864b2
No known key found for this signature in database
GPG Key ID: B9A4F245CD67BDE8

View File

@ -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;