diff --git a/src/info.rs b/src/info.rs index 6e62f5d30..b98f9b53e 100644 --- a/src/info.rs +++ b/src/info.rs @@ -394,7 +394,7 @@ impl Info { args.push("--no-merges"); } - args.push("--pretty=%cr\t%an"); + args.push("--pretty=%cr\t%ae\t%an"); let output = Command::new("git") .args(args) @@ -489,10 +489,13 @@ impl Info { fn get_authors(git_history: &[String], n: usize) -> Vec<(String, usize, usize)> { let mut authors = std::collections::HashMap::new(); + let mut author_name_by_email = std::collections::HashMap::new(); let mut total_commits = 0; for line in git_history { - let commit_author = line.split('\t').collect::>()[1].to_string(); - let commit_count = authors.entry(commit_author.to_string()).or_insert(0); + let author_email = line.split('\t').collect::>()[1].to_string(); + let author_name = line.split('\t').collect::>()[2].to_string(); + let commit_count = authors.entry(author_email.to_string()).or_insert(0); + author_name_by_email.entry(author_email.to_string()).or_insert(author_name); *commit_count += 1; total_commits += 1; } @@ -506,7 +509,7 @@ impl Info { .into_iter() .map(|(author, count)| { ( - author.trim_matches('\'').to_string(), + author_name_by_email.get(&author).unwrap().trim_matches('\'').to_string(), count, count * 100 / total_commits, )