@@ -11,6 +11,7 @@ class CaseIndifferentMap {
11
11
_map = new Map ( ) ;
12
12
13
13
get ( key ) { return this . _map . get ( key . toLowerCase ( ) ) ; }
14
+ has ( key ) { return this . _map . has ( key . toLowerCase ( ) ) ; }
14
15
set ( key , value ) { return this . _map . set ( key . toLowerCase ( ) , value ) ; }
15
16
}
16
17
@@ -64,6 +65,30 @@ const mailmap = new CaseIndifferentMap();
64
65
}
65
66
}
66
67
68
+ const previousAuthors = new CaseIndifferentMap ( ) ;
69
+ {
70
+ const lines = fs . readFileSync ( path . resolve ( __dirname , '../' , 'AUTHORS' ) ,
71
+ { encoding : 'utf8' } ) . split ( '\n' ) ;
72
+ for ( let line of lines ) {
73
+ line = line . trim ( ) ;
74
+ if ( line . startsWith ( '#' ) || line === '' ) continue ;
75
+
76
+ let match ;
77
+ if ( match = line . match ( / ^ ( [ ^ < ] + ) \s + ( < [ ^ > ] + > ) $ / ) ) {
78
+ const name = match [ 1 ] ;
79
+ const email = match [ 2 ] ;
80
+ if ( previousAuthors . has ( name ) ) {
81
+ const emails = previousAuthors . get ( name ) ;
82
+ emails . push ( email ) ;
83
+ } else {
84
+ previousAuthors . set ( name , [ email ] ) ;
85
+ }
86
+ } else {
87
+ console . warn ( 'Unknown AUTHORS format:' , line ) ;
88
+ }
89
+ }
90
+ }
91
+
67
92
const seen = new Set ( ) ;
68
93
69
94
// Support regular git author metadata, as well as `Author:` and
@@ -93,6 +118,11 @@ rl.on('line', (line) => {
93
118
94
119
seen . add ( email ) ;
95
120
output . write ( `${ author } ${ email } \n` ) ;
121
+ const duplicate = previousAuthors . get ( author ) ;
122
+ if ( duplicate && ! duplicate . includes ( email ) ) {
123
+ console . warn ( 'Author name already in AUTHORS file. Possible duplicate:' ) ;
124
+ console . warn ( ` ${ author } <${ email } >` ) ;
125
+ }
96
126
} ) ;
97
127
98
128
rl . on ( 'close' , ( ) => {
0 commit comments