Identify author by email
@@ -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 names = std::collections::HashMap::new();
let mut total_commits = 0;
for line in git_history {
let commit_author = line.split('\t').collect::<Vec<_>>()[1].to_string();
+ let author_name = line.split('\t').collect::<Vec<_>>()[2].to_string();
let commit_count = authors.entry(commit_author.to_string()).or_insert(0);
+ names.entry(commit_author.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(),
+ names.get(&author).unwrap().trim_matches('\'').to_string(),
count,
count * 100 / total_commits,
)
