Skip to content

Commit 7947bb2

Browse files
committed
pr_checker: ignore private emails
1 parent 9ee2ec7 commit 7947bb2

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
@@ -284,6 +284,13 @@ class PRChecker {
284284

285285
isOddAuthor(commit) {
286286
const { pr, collaboratorEmails } = this;
287+
288+
// They have turned on the private email feature, can't really check
289+
// anything, GitHub should know how to link that, see nodejs/node#15489
290+
if (!pr.author.email) {
291+
return false;
292+
}
293+
287294
// If they have added the alternative email to their account,
288295
// commit.authoredByCommitter should be set to true by Github
289296
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');
@@ -550,6 +551,28 @@ describe('PRChecker', () => {
550551
assert(!status);
551552
cli.assertCalledWith(expectedLogs);
552553
});
554+
555+
it('should skip checking odd commits for first timers ' +
556+
'with private emails', () => {
557+
const cli = new TestCLI();
558+
559+
const expectedLogs = {};
560+
561+
const options = {
562+
pr: firstTimerPrivatePR,
563+
reviewers: allGreenReviewers,
564+
comments: commentsWithLGTM,
565+
reviews: approvingReviews,
566+
commits: oddCommits,
567+
collaborators
568+
};
569+
const checker = new PRChecker(cli, options, argv);
570+
571+
assert(checker.authorIsNew());
572+
const status = checker.checkAuthor();
573+
assert(status);
574+
cli.assertCalledWith(expectedLogs);
575+
});
553576
});
554577

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

0 commit comments

Comments
 (0)