@@ -11,6 +11,7 @@ class CaseIndifferentMap {
1111 _map = new Map ( ) ;
1212
1313 get ( key ) { return this . _map . get ( key . toLowerCase ( ) ) ; }
14+ has ( key ) { return this . _map . has ( key . toLowerCase ( ) ) ; }
1415 set ( key , value ) { return this . _map . set ( key . toLowerCase ( ) , value ) ; }
1516}
1617
@@ -64,6 +65,30 @@ const mailmap = new CaseIndifferentMap();
6465 }
6566}
6667
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+
6792const seen = new Set ( ) ;
6893
6994// Support regular git author metadata, as well as `Author:` and
@@ -93,6 +118,11 @@ rl.on('line', (line) => {
93118
94119 seen . add ( email ) ;
95120 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+ }
96126} ) ;
97127
98128rl . on ( 'close' , ( ) => {
0 commit comments