Skip to content

Commit

Permalink
Switch to github.pr.user.login since commits[].author.login is un…
Browse files Browse the repository at this point in the history
…defined.

As demonstrated in the Danger test[0] on #3444,
the `author` property is not always set.  While it could make sense to
individually look at each individual commit's "login", Git commits are not
always tied to GitHub users so it seems more relevant to look at the GitHub
login of the user (or bot!) opening the PR, when making decisions about
whether to apply bot-only policies.

[0]: https://circleci.com/gh/apollographql/apollo-client/8427
  • Loading branch information
abernix committed May 23, 2018
1 parent 5d3889c commit 7baaa91
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions dangerfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,17 @@ const raiseIssueAboutPaths = (
}
};

const authors = commits.map(x => x.author.login);
const isBot = authors.some(x => ['greenkeeper', 'renovate'].indexOf(x) > -1);
console.log("GitHub PR Username:", pr && pr.user && pr.user.login);

const githubBotUsernames = [
'greenkeeper',
'renovate',
];

const isBot = pr
&& pr.user
&& pr.user.login
&& githubBotUsernames.includes(pr.user.login);

// Rules
if (!isBot) {
Expand Down

0 comments on commit 7baaa91

Please sign in to comment.