File tree Expand file tree Collapse file tree 4 files changed +69
-3
lines changed Expand file tree Collapse file tree 4 files changed +69
-3
lines changed Original file line number Diff line number Diff line change @@ -34,8 +34,16 @@ class PRSummary {
3434 cli . table ( 'Title' , `${ title } (#${ prid } )` ) ;
3535 const authorHint =
3636 this . data . authorIsNew ( ) ? ', first-time contributor' : '' ;
37- cli . table ( 'Author' ,
38- `${ author . name } <${ author . email } > (@${ author . login } ${ authorHint } )` ) ;
37+
38+ if ( author . name && author . email ) {
39+ cli . table ( 'Author' ,
40+ `${ author . name } <${ author . email } > (@${ author . login } ${ authorHint } )` ) ;
41+ } else {
42+ // Unable to retrive email/name of the PR Author
43+ cli . warn ( 'Could not retrieve the email or name ' +
44+ "of the PR author's from user's GitHub profile!" ) ;
45+ }
46+
3947 cli . table ( 'Branch' , `${ branch } ` ) ;
4048 cli . table ( 'Labels' , `${ labelStr } ` ) ;
4149
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ const firstTimerPrivatePR = readJSON('first_timer_pr_with_private_email.json');
5959const semverMajorPR = readJSON ( 'semver_major_pr.json' ) ;
6060const fixAndRefPR = readJSON ( 'pr_with_fixes_and_refs.json' ) ;
6161const conflictingPR = readJSON ( 'conflicting_pr.json' ) ;
62+ const emptyProfilePR = readJSON ( 'empty_profile_pr.json' ) ;
6263const closedPR = readJSON ( './closed_pr.json' ) ;
6364const mergedPR = readJSON ( './merged_pr.json' ) ;
6465const readme = readFile ( './README/README.md' ) ;
@@ -90,6 +91,7 @@ module.exports = {
9091 semverMajorPR,
9192 fixAndRefPR,
9293 conflictingPR,
94+ emptyProfilePR,
9395 readme,
9496 readmeNoTsc,
9597 readmeNoTscE,
Original file line number Diff line number Diff line change 1+ {
2+ "createdAt" : " 2017-10-24T11:13:43Z" ,
3+ "authorAssociation" : " COLLABORATOR" ,
4+ "author" : {
5+ "login" : " pr_author" ,
6+ "email" : " " ,
7+ "name" : null
8+ },
9+ "url" : " https://github.com/nodejs/node/pull/18721" ,
10+ "bodyHTML" : " <p>Fix mdn links</p>" ,
11+ "bodyText" : " Fix mdn links" ,
12+ "labels" : {
13+ "nodes" : [
14+ {
15+ "name" : " doc"
16+ }
17+ ]
18+ },
19+ "title" : " doc: fix mdn links" ,
20+ "baseRefName" : " master" ,
21+ "headRefName" : " fix-links"
22+ }
Original file line number Diff line number Diff line change 44 oddCommits,
55 simpleCommits,
66 firstTimerPR,
7- semverMajorPR
7+ semverMajorPR,
8+ emptyProfilePR
89} = require ( '../fixtures/data' ) ;
910const TestCLI = require ( '../fixtures/test_cli' ) ;
1011const PRSummary = require ( '../../lib/pr_summary' ) ;
@@ -86,4 +87,37 @@ describe('PRSummary', () => {
8687 summary . display ( ) ;
8788 cli . assertCalledWith ( expectedLogs ) ;
8889 } ) ;
90+
91+ it ( 'displays warning if pr author/email is not present' , ( ) => {
92+ const cli = new TestCLI ( ) ;
93+ const prData = {
94+ pr : emptyProfilePR ,
95+ commits : simpleCommits ,
96+ authorIsNew ( ) {
97+ return false ;
98+ }
99+ } ;
100+
101+ const expectedLogs = {
102+ log : [
103+ [ ' - doc: some changes' ] ,
104+ [ ' - Their Github Account email <[email protected] >' ] 105+ ] ,
106+ table : [
107+ [ 'Title' , 'doc: fix mdn links (#16348)' ] ,
108+ [ 'Branch' , 'pr_author:fix-links -> nodejs:master' ] ,
109+ [ 'Labels' , 'doc' ] ,
110+ [ 'Commits' , '1' ] ,
111+ [ 'Committers' , '1' ]
112+ ] ,
113+ warn : [
114+ [ 'Could not retrieve the email or name ' +
115+ "of the PR author's from user's GitHub profile!" ]
116+ ]
117+ } ;
118+
119+ const summary = new PRSummary ( argv , cli , prData ) ;
120+ summary . display ( ) ;
121+ cli . assertCalledWith ( expectedLogs ) ;
122+ } ) ;
89123} ) ;
You can’t perform that action at this time.
0 commit comments