@@ -36,12 +36,16 @@ async function countFileAuthorStats(repoPath, filePath) {
3636
3737 if ( ! commits [ hash ] ) {
3838 i ++ ;
39- let authorEmail ;
39+ let authorEmail , authorName ;
4040
4141 while ( lines [ i ] [ 0 ] !== '\t' ) { // source line starts prefixed by tab
4242 if ( lines [ i ] . startsWith ( 'author-mail ' ) ) {
4343 authorEmail = lines [ i ] . slice ( 'author-mail <' . length , - 1 ) ;
4444 }
45+
46+ if ( lines [ i ] . startsWith ( 'author ' ) ) {
47+ authorName = lines [ i ] . slice ( 'author ' . length ) ;
48+ }
4549 i ++ ;
4650 }
4751
@@ -54,7 +58,8 @@ async function countFileAuthorStats(repoPath, filePath) {
5458 // next lines from same commit may be non-empty, but there will be no commit info
5559 commits [ hash ] = {
5660 linesCount : sourceLine ? 1 : 0 , // ignore blank lines
57- authorEmail
61+ authorEmail,
62+ authorName
5863 } ;
5964
6065 } else {
@@ -67,21 +72,25 @@ async function countFileAuthorStats(repoPath, filePath) {
6772 }
6873
6974 assert ( commits [ hash ] . authorEmail ) ;
75+ assert ( commits [ hash ] . authorName ) ;
7076
7177 // some commits may have no lines yet
7278 }
7379
7480
81+ let fileStats = Object . create ( null ) ;
82+ let authorEmailToName = Object . create ( null ) ;
7583
76- let stats = Object . create ( null ) ;
7784 for ( let hash in commits ) {
7885 let commit = commits [ hash ] ;
7986 if ( ! commit . linesCount ) continue ; // ignore commit with blank lines only
80- stats [ commit . authorEmail ] = ( stats [ commit . authorEmail ] || 0 ) + commit . linesCount ;
87+ authorEmailToName [ commit . authorEmail ] = commit . authorName ;
88+ fileStats [ commit . authorEmail ] = ( fileStats [ commit . authorEmail ] || 0 ) + commit . linesCount ;
8189 }
8290
83- debug ( stats ) ;
84- return stats ;
91+ debug ( fileStats ) ;
92+
93+ return { fileStats, authorEmailToName} ;
8594}
8695
8796module . exports = countFileAuthorStats ;
0 commit comments