summaryrefslogtreecommitdiff
path: root/contrib/stats/mailmap.pl
blob: 4b852e2455bab324e3bd16e02ec712fbacbf34b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/perl -w
my %mailmap = ();
open I, "<", ".mailmap";
while (<I>) {
	chomp;
	next if /^#/;
	if (my ($author, $mail) = /^(.*?)\s+<(.+)>$/) {
		$mailmap{$mail} = $author;
	}
}
close I;
 
my %mail2author = ();
open I, "git log --pretty='format:%ae	%an' |";
while (<I>) {
	chomp;
	my ($mail, $author) = split(/\t/, $_);
	next if exists $mailmap{$mail};
	$mail2author{$mail} ||= {};
	$mail2author{$mail}{$author} ||= 0;
	$mail2author{$mail}{$author}++;
}
close I;
 
while (my ($mail, $authorcount) = each %mail2author) {
	# %$authorcount is ($author => $count);
	# sort and show the names from the most frequent ones.
	my @names = (map { $_->[0] }
		sort { $b->[1] <=> $a->[1] }
		map { [$_, $authorcount->{$_}] }
		keys %$authorcount);
	if (1 < @names) {
		for (@names) {
			print "$_ <$mail>\n";
		}
	}
}