Skip to content

Commit c652c5b

Browse files
committed
pr_checker: ignore private emails
1 parent b22d056 commit c652c5b

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

lib/pr_checker.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,13 @@ class PRChecker {
263263

264264
isOddAuthor(commit) {
265265
const { pr, collaboratorEmails } = this;
266+
267+
// They have turned on the private email feature, can't really check
268+
// anything, GitHub should know how to link that, see nodejs/node#15489
269+
if (!pr.author.email) {
270+
return false;
271+
}
272+
266273
// If they have added the alternative email to their account,
267274
// commit.authoredByCommitter should be set to true by Github
268275
if (commit.authoredByCommitter) {

test/fixtures/data.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const collaborators = new Map(
5555
);
5656

5757
const firstTimerPR = readJSON('first_timer_pr.json');
58+
const firstTimerPrivatePR = readJSON('first_timer_pr_with_private_email.json');
5859
const semverMajorPR = readJSON('semver_major_pr.json');
5960
const fixAndRefPR = readJSON('pr_with_fixes_and_refs.json');
6061
const conflictingPR = readJSON('conflicting_pr.json');
@@ -83,6 +84,7 @@ module.exports = {
8384
mulipleCommitsAfterCi,
8485
collaborators,
8586
firstTimerPR,
87+
firstTimerPrivatePR,
8688
semverMajorPR,
8789
fixAndRefPR,
8890
conflictingPR,
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"createdAt": "2017-10-24T11:13:43Z",
3+
"authorAssociation": "FIRST_TIMER",
4+
"author": {
5+
"login": "pr_author",
6+
"email": ""
7+
},
8+
"url": "https://github.com/nodejs/node/pull/16438",
9+
"bodyHTML": "<p>Awesome changes</p>",
10+
"bodyText": "Awesome changes",
11+
"labels": {
12+
"nodes": [
13+
{
14+
"name": "test"
15+
},
16+
{
17+
"name": "doc"
18+
}
19+
]
20+
},
21+
"title": "test: awesome changes",
22+
"baseRefName": "master",
23+
"headRefName": "awesome-changes"
24+
}

test/unit/pr_checker.test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const {
2323
mulipleCommitsAfterCi,
2424
collaborators,
2525
firstTimerPR,
26+
firstTimerPrivatePR,
2627
semverMajorPR,
2728
conflictingPR
2829
} = require('../fixtures/data');
@@ -436,6 +437,28 @@ describe('PRChecker', () => {
436437
assert(!status);
437438
cli.assertCalledWith(expectedLogs);
438439
});
440+
441+
it('should skip checking odd commits for first timers ' +
442+
'with private emails', () => {
443+
const cli = new TestCLI();
444+
445+
const expectedLogs = {};
446+
447+
const options = {
448+
pr: firstTimerPrivatePR,
449+
reviewers: allGreenReviewers,
450+
comments: commentsWithLGTM,
451+
reviews: approvingReviews,
452+
commits: oddCommits,
453+
collaborators
454+
};
455+
const checker = new PRChecker(cli, options, argv);
456+
457+
assert(checker.authorIsNew());
458+
const status = checker.checkAuthor();
459+
assert(status);
460+
cli.assertCalledWith(expectedLogs);
461+
});
439462
});
440463

441464
describe('checkCommitsAfterReview', () => {

0 commit comments

Comments
 (0)