Skip to content

Commit

Permalink
pr_checker: ignore private emails
Browse files Browse the repository at this point in the history
  • Loading branch information
joyeecheung committed Nov 23, 2017
1 parent b22d056 commit c652c5b
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/pr_checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,13 @@ class PRChecker {

isOddAuthor(commit) {
const { pr, collaboratorEmails } = this;

// They have turned on the private email feature, can't really check
// anything, GitHub should know how to link that, see nodejs/node#15489
if (!pr.author.email) {
return false;
}

// If they have added the alternative email to their account,
// commit.authoredByCommitter should be set to true by Github
if (commit.authoredByCommitter) {
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const collaborators = new Map(
);

const firstTimerPR = readJSON('first_timer_pr.json');
const firstTimerPrivatePR = readJSON('first_timer_pr_with_private_email.json');
const semverMajorPR = readJSON('semver_major_pr.json');
const fixAndRefPR = readJSON('pr_with_fixes_and_refs.json');
const conflictingPR = readJSON('conflicting_pr.json');
Expand Down Expand Up @@ -83,6 +84,7 @@ module.exports = {
mulipleCommitsAfterCi,
collaborators,
firstTimerPR,
firstTimerPrivatePR,
semverMajorPR,
fixAndRefPR,
conflictingPR,
Expand Down
24 changes: 24 additions & 0 deletions test/fixtures/first_timer_pr_with_private_email.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"createdAt": "2017-10-24T11:13:43Z",
"authorAssociation": "FIRST_TIMER",
"author": {
"login": "pr_author",
"email": ""
},
"url": "https://github.com/nodejs/node/pull/16438",
"bodyHTML": "<p>Awesome changes</p>",
"bodyText": "Awesome changes",
"labels": {
"nodes": [
{
"name": "test"
},
{
"name": "doc"
}
]
},
"title": "test: awesome changes",
"baseRefName": "master",
"headRefName": "awesome-changes"
}
23 changes: 23 additions & 0 deletions test/unit/pr_checker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const {
mulipleCommitsAfterCi,
collaborators,
firstTimerPR,
firstTimerPrivatePR,
semverMajorPR,
conflictingPR
} = require('../fixtures/data');
Expand Down Expand Up @@ -436,6 +437,28 @@ describe('PRChecker', () => {
assert(!status);
cli.assertCalledWith(expectedLogs);
});

it('should skip checking odd commits for first timers ' +
'with private emails', () => {
const cli = new TestCLI();

const expectedLogs = {};

const options = {
pr: firstTimerPrivatePR,
reviewers: allGreenReviewers,
comments: commentsWithLGTM,
reviews: approvingReviews,
commits: oddCommits,
collaborators
};
const checker = new PRChecker(cli, options, argv);

assert(checker.authorIsNew());
const status = checker.checkAuthor();
assert(status);
cli.assertCalledWith(expectedLogs);
});
});

describe('checkCommitsAfterReview', () => {
Expand Down

0 comments on commit c652c5b

Please sign in to comment.