aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2009-09-21 20:04:21 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-09-22 10:17:46 -0400
commit8cbb3a77e1a91073fb279a495a11d5093461dfe5 (patch)
tree847d483a9605e0974df243a4de45487aa31b2aa0 /scripts
parent0e70e83dfd40cac47e1fc3e2f1c7b893ea0cd2f8 (diff)
scripts/get_maintainer.pl: add .mailmap use, shell and email cleanups
Add reading and using .mailmap file if it exists Convert address entries in .mailmap to first encountered address Don't terminate shell commands with \n Strip characters found after sign-offs by: name <address> [stripped] Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/get_maintainer.pl72
1 files changed, 65 insertions, 7 deletions
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index 1200d724e73b..8b80b5abb860 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -152,6 +152,36 @@ while (<MAINT>) {
152} 152}
153close(MAINT); 153close(MAINT);
154 154
155my %mailmap;
156
157open(MAILMAP, "<${lk_path}.mailmap") || warn "$P: Can't open .mailmap\n";
158while (<MAILMAP>) {
159 my $line = $_;
160
161 next if ($line =~ m/^\s*#/);
162 next if ($line =~ m/^\s*$/);
163
164 my ($name, $address) = parse_email($line);
165 $line = format_email($name, $address);
166
167 next if ($line =~ m/^\s*$/);
168
169 if (exists($mailmap{$name})) {
170 my $obj = $mailmap{$name};
171 push(@$obj, $address);
172 } else {
173 my @arr = ($address);
174 $mailmap{$name} = \@arr;
175 }
176}
177close(MAILMAP);
178
179foreach my $name (sort {$mailmap{$a} <=> $mailmap{$b}} keys %mailmap) {
180 my $obj = $mailmap{$name};
181 foreach my $address (@$obj) {
182 }
183}
184
155## use the filenames on the command line or find the filenames in the patchfiles 185## use the filenames on the command line or find the filenames in the patchfiles
156 186
157my @files = (); 187my @files = ();
@@ -403,12 +433,12 @@ sub parse_email {
403 my $name = ""; 433 my $name = "";
404 my $address = ""; 434 my $address = "";
405 435
406 if ($formatted_email =~ /^([^<]+)<(.*\@.*)>$/) { 436 if ($formatted_email =~ /^([^<]+)<(.*\@.*)>.*$/) {
407 $name = $1; 437 $name = $1;
408 $address = $2; 438 $address = $2;
409 } elsif ($formatted_email =~ /^<(.*\@.*)>$/) { 439 } elsif ($formatted_email =~ /^\s*<(.*\@.*)>.*$/) {
410 $address = $1; 440 $address = $1;
411 } elsif ($formatted_email =~ /^(.*\@.*)$/) { 441 } elsif ($formatted_email =~ /^\s*(.*\@.*)$/) {
412 $address = $1; 442 $address = $1;
413 } 443 }
414 444
@@ -557,6 +587,29 @@ sub which {
557 return ""; 587 return "";
558} 588}
559 589
590sub mailmap {
591 my @lines = @_;
592 my %hash;
593
594 foreach my $line (@lines) {
595 my ($name, $address) = parse_email($line);
596 if (!exists($hash{$name})) {
597 $hash{$name} = $address;
598 }
599 if (exists($mailmap{$name})) {
600 my $obj = $mailmap{$name};
601 foreach my $map_address (@$obj) {
602 if (($map_address eq $address) &&
603 ($map_address ne $hash{$name})) {
604 $line = format_email($name, $hash{$name});
605 }
606 }
607 }
608 }
609
610 return @lines;
611}
612
560sub recent_git_signoffs { 613sub recent_git_signoffs {
561 my ($file) = @_; 614 my ($file) = @_;
562 615
@@ -592,9 +645,10 @@ sub recent_git_signoffs {
592 # cut -f2- -d":" 645 # cut -f2- -d":"
593 s/.*:\s*(.+)\s*/$1/ for (@lines); 646 s/.*:\s*(.+)\s*/$1/ for (@lines);
594 647
648 $total_sign_offs = @lines;
649
595 @lines = mailmap(@lines); 650 @lines = mailmap(@lines);
596 651
597 $total_sign_offs = @lines;
598 @lines = sort(@lines); 652 @lines = sort(@lines);
599 # uniq -c 653 # uniq -c
600 foreach my $line (@lines) { 654 foreach my $line (@lines) {
@@ -655,12 +709,12 @@ sub git_assign_blame {
655 my $diff_start = $2; 709 my $diff_start = $2;
656 my $diff_length = $3; 710 my $diff_length = $3;
657 next if (!("$file" eq "$diff_file")); 711 next if (!("$file" eq "$diff_file"));
658 $cmd = "git blame -l -L $diff_start,+$diff_length $file\n"; 712 $cmd = "git blame -l -L $diff_start,+$diff_length $file";
659 @commits = save_commits($cmd, @commits); 713 @commits = save_commits($cmd, @commits);
660 } 714 }
661 } else { 715 } else {
662 if (-f $file) { 716 if (-f $file) {
663 $cmd = "git blame -l $file\n"; 717 $cmd = "git blame -l $file";
664 @commits = save_commits($cmd, @commits); 718 @commits = save_commits($cmd, @commits);
665 } 719 }
666 } 720 }
@@ -678,11 +732,15 @@ sub git_assign_blame {
678 if (!$email_git_penguin_chiefs) { 732 if (!$email_git_penguin_chiefs) {
679 @lines = grep(!/${penguin_chiefs}/i, @lines); 733 @lines = grep(!/${penguin_chiefs}/i, @lines);
680 } 734 }
735
681 # cut -f2- -d":" 736 # cut -f2- -d":"
682 s/.*:\s*(.+)\s*/$1/ for (@lines); 737 s/.*:\s*(.+)\s*/$1/ for (@lines);
683 738
684 $hash{$_}++ for @lines;
685 $total_sign_offs += @lines; 739 $total_sign_offs += @lines;
740
741 @lines = mailmap(@lines);
742
743 $hash{$_}++ for @lines;
686 } 744 }
687 745
688 $count = 0; 746 $count = 0;