@@ -22,27 +22,33 @@ async function runGitCommand(cmd, mapFn) {
2222 const errorHandler = new Promise (
2323 ( _ , reject ) => childProcess . on ( 'error' , reject )
2424 ) ;
25- const returnedSet = new Set ( ) ;
25+ let returnValue = mapFn ? new Set ( ) : '' ;
2626 await Promise . race ( [ errorHandler , Promise . resolve ( ) ] ) ;
27+ // If no mapFn, return the value. If there is a mapFn, use it to make a Set to
28+ // return.
2729 for await ( const line of lines ) {
2830 await Promise . race ( [ errorHandler , Promise . resolve ( ) ] ) ;
29- const val = mapFn ( line ) ;
30- if ( val ) {
31- returnedSet . add ( val ) ;
31+ if ( mapFn ) {
32+ const val = mapFn ( line ) ;
33+ if ( val ) {
34+ returnValue . add ( val ) ;
35+ }
36+ } else {
37+ returnValue += line ;
3238 }
3339 }
34- return Promise . race ( [ errorHandler , Promise . resolve ( returnedSet ) ] ) ;
40+ return Promise . race ( [ errorHandler , Promise . resolve ( returnValue ) ] ) ;
3541}
3642
3743// Get all commit authors during the time period.
3844const authors = await runGitCommand (
39- `git shortlog -n -s --max-count="${ SINCE } " HEAD` ,
45+ `git shortlog -n -s --email -- max-count="${ SINCE } " HEAD` ,
4046 ( line ) => line . trim ( ) . split ( '\t' , 2 ) [ 1 ]
4147) ;
4248
4349// Get all commit landers during the time period.
4450const landers = await runGitCommand (
45- `git shortlog -n -s -c --max-count="${ SINCE } " HEAD` ,
51+ `git shortlog -n -s -c --email -- max-count="${ SINCE } " HEAD` ,
4652 ( line ) => line . trim ( ) . split ( '\t' , 2 ) [ 1 ]
4753) ;
4854
@@ -52,7 +58,7 @@ const approvingReviewers = await runGitCommand(
5258 ( line ) => / ^ R e v i e w e d - B y : ( [ ^ < ] + ) / . exec ( line ) [ 1 ] . trim ( )
5359) ;
5460
55- async function retrieveCollaboratorsFromReadme ( ) {
61+ async function getCollaboratorsFromReadme ( ) {
5662 const readmeText = readline . createInterface ( {
5763 input : fs . createReadStream ( new URL ( '../README.md' , import . meta. url ) ) ,
5864 crlfDelay : Infinity ,
@@ -69,14 +75,22 @@ async function retrieveCollaboratorsFromReadme() {
6975 break ;
7076 }
7177 if ( line . startsWith ( '**' ) && isCollaborator ) {
72- returnedArray . push ( line . split ( '**' , 2 ) [ 1 ] . trim ( ) ) ;
78+ const [ , name , email ] = / ^ \* \* ( [ ^ * ] + ) \* \* & l t ; ( .+ ) & g t ; / . exec ( line ) ;
79+ const mailmap = await runGitCommand (
80+ `git check-mailmap '${ name } <${ email } >'`
81+ ) ;
82+ returnedArray . push ( {
83+ name,
84+ email,
85+ mailmap,
86+ } ) ;
7387 }
7488 }
7589 return returnedArray ;
7690}
7791
7892// Get list of current collaborators from README.md.
79- const collaborators = await retrieveCollaboratorsFromReadme ( ) ;
93+ const collaborators = await getCollaboratorsFromReadme ( ) ;
8094
8195console . log ( `In the last ${ SINCE } commits:\n` ) ;
8296console . log ( `* ${ authors . size . toLocaleString ( ) } authors have made commits.` ) ;
@@ -85,10 +99,10 @@ console.log(`* ${approvingReviewers.size.toLocaleString()} reviewers have approv
8599console . log ( `* ${ collaborators . length . toLocaleString ( ) } collaborators currently in the project.` ) ;
86100
87101const inactive = collaborators . filter ( ( collaborator ) =>
88- ! authors . has ( collaborator ) &&
89- ! landers . has ( collaborator ) &&
90- ! approvingReviewers . has ( collaborator )
91- ) ;
102+ ! authors . has ( collaborator . mailmap ) &&
103+ ! landers . has ( collaborator . mailmap ) &&
104+ ! approvingReviewers . has ( collaborator . name )
105+ ) . map ( ( collaborator ) => collaborator . name ) ;
92106
93107if ( inactive . length ) {
94108 console . log ( '\nInactive collaborators:\n' ) ;
0 commit comments