@@ -39,25 +39,13 @@ const mailmap = new CaseIndifferentMap();
3939 line = line . trim ( ) ;
4040 if ( line . startsWith ( '#' ) || line === '' ) continue ;
4141
42- let match ;
43- // Replaced Name <original@example.com>
44- if ( match = line . match ( / ^ ( [ ^ < ] + ) \s + ( < [ ^ > ] + > ) $ / ) ) {
45- mailmap . set ( match [ 2 ] . toLowerCase ( ) , {
46- author : match [ 1 ] , email : match [ 2 ]
47- } ) ;
48- // <replaced@example.com> <original@example.com>
49- } else if ( match = line . match ( / ^ < ( [ ^ > ] + ) > \s + ( < [ ^ > ] + > ) $ / ) ) {
50- mailmap . set ( match [ 2 ] . toLowerCase ( ) , { email : match [ 1 ] } ) ;
51- // Replaced Name <replaced@example.com> <original@example.com>
52- } else if ( match = line . match ( / ^ ( [ ^ < ] + ) \s + ( < [ ^ > ] + > ) \s + ( < [ ^ > ] + > ) $ / ) ) {
53- mailmap . set ( match [ 3 ] . toLowerCase ( ) , {
54- author : match [ 1 ] , email : match [ 2 ]
55- } ) ;
56- // Replaced Name <replaced@example.com> Original Name <original@example.com>
57- } else if ( match =
58- line . match ( / ^ ( [ ^ < ] + ) \s + ( < [ ^ > ] + > ) \s + ( [ ^ < ] + ) \s + ( < [ ^ > ] + > ) $ / ) ) {
59- mailmap . set ( match [ 3 ] + '\0' + match [ 4 ] . toLowerCase ( ) , {
60- author : match [ 1 ] , email : match [ 2 ]
42+ const match = line . match ( / ^ (?: ( [ ^ < ] + ) \s + ) ? (?: ( < [ ^ > ] + > ) \s + ) ? (?: ( [ ^ < ] + ) \s + ) ? ( < [ ^ > ] + > ) $ / ) ;
43+ if ( match ) {
44+ const [ , replaceName , replaceEmail , originalName , originalEmail ] = match ;
45+ const key = originalName ? `${ originalName } \0${ originalEmail . toLocaleLowerCase ( ) } ` : originalEmail . toLowerCase ( ) ;
46+ mailmap . set ( key , {
47+ author : replaceName || originalName ,
48+ email : replaceEmail || originalEmail ,
6149 } ) ;
6250 } else {
6351 console . warn ( 'Unknown .mailmap format:' , line ) ;
@@ -73,8 +61,8 @@ const previousAuthors = new CaseIndifferentMap();
7361 line = line . trim ( ) ;
7462 if ( line . startsWith ( '#' ) || line === '' ) continue ;
7563
76- let match ;
77- if ( match = line . match ( / ^ ( [ ^ < ] + ) \s + ( < [ ^ > ] + > ) $ / ) ) {
64+ const match = line . match ( / ^ ( [ ^ < ] + ) \s + ( < [ ^ > ] + > ) $ / ) ;
65+ if ( match ) {
7866 const name = match [ 1 ] ;
7967 const email = match [ 2 ] ;
8068 if ( previousAuthors . has ( name ) ) {
0 commit comments