@@ -22,27 +22,33 @@ async function runGitCommand(cmd, mapFn) {
22
22
const errorHandler = new Promise (
23
23
( _ , reject ) => childProcess . on ( 'error' , reject )
24
24
) ;
25
- const returnedSet = new Set ( ) ;
25
+ let returnValue = mapFn ? new Set ( ) : '' ;
26
26
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.
27
29
for await ( const line of lines ) {
28
30
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 ;
32
38
}
33
39
}
34
- return Promise . race ( [ errorHandler , Promise . resolve ( returnedSet ) ] ) ;
40
+ return Promise . race ( [ errorHandler , Promise . resolve ( returnValue ) ] ) ;
35
41
}
36
42
37
43
// Get all commit authors during the time period.
38
44
const authors = await runGitCommand (
39
- `git shortlog -n -s --max-count="${ SINCE } " HEAD` ,
45
+ `git shortlog -n -s --email -- max-count="${ SINCE } " HEAD` ,
40
46
( line ) => line . trim ( ) . split ( '\t' , 2 ) [ 1 ]
41
47
) ;
42
48
43
49
// Get all commit landers during the time period.
44
50
const landers = await runGitCommand (
45
- `git shortlog -n -s -c --max-count="${ SINCE } " HEAD` ,
51
+ `git shortlog -n -s -c --email -- max-count="${ SINCE } " HEAD` ,
46
52
( line ) => line . trim ( ) . split ( '\t' , 2 ) [ 1 ]
47
53
) ;
48
54
@@ -52,7 +58,7 @@ const approvingReviewers = await runGitCommand(
52
58
( line ) => / ^ R e v i e w e d - B y : ( [ ^ < ] + ) / . exec ( line ) [ 1 ] . trim ( )
53
59
) ;
54
60
55
- async function retrieveCollaboratorsFromReadme ( ) {
61
+ async function getCollaboratorsFromReadme ( ) {
56
62
const readmeText = readline . createInterface ( {
57
63
input : fs . createReadStream ( new URL ( '../README.md' , import . meta. url ) ) ,
58
64
crlfDelay : Infinity ,
@@ -69,14 +75,22 @@ async function retrieveCollaboratorsFromReadme() {
69
75
break ;
70
76
}
71
77
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
+ } ) ;
73
87
}
74
88
}
75
89
return returnedArray ;
76
90
}
77
91
78
92
// Get list of current collaborators from README.md.
79
- const collaborators = await retrieveCollaboratorsFromReadme ( ) ;
93
+ const collaborators = await getCollaboratorsFromReadme ( ) ;
80
94
81
95
console . log ( `In the last ${ SINCE } commits:\n` ) ;
82
96
console . log ( `* ${ authors . size . toLocaleString ( ) } authors have made commits.` ) ;
@@ -85,10 +99,10 @@ console.log(`* ${approvingReviewers.size.toLocaleString()} reviewers have approv
85
99
console . log ( `* ${ collaborators . length . toLocaleString ( ) } collaborators currently in the project.` ) ;
86
100
87
101
const 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 ) ;
92
106
93
107
if ( inactive . length ) {
94
108
console . log ( '\nInactive collaborators:\n' ) ;
0 commit comments