diff options
| author | Joe Perches <joe@perches.com> | 2009-09-21 20:04:22 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-22 10:17:46 -0400 |
| commit | 11ecf53c97863a0609db3816d82f1d0ddf3d2bc2 (patch) | |
| tree | bea4e471f97f7a5535e03c1e38cdbd588b1a747e /scripts | |
| parent | 42498316132e89ca2835b977a7cfb32a83e97b35 (diff) | |
scripts/get_maintainer.pl: add --remove-duplicates
Allow control over the elimination of duplicate email names and addresses
--remove-duplicates will use the first email name or address presented
--noremove-duplicates will emit all names and addresses
--remove-duplicates is enabled by default
For instance:
$ ./scripts/get_maintainer.pl -f drivers/char/tty_ioctl.c
Greg Kroah-Hartman <gregkh@suse.de>
Alan Cox <alan@linux.intel.com>
Mike Frysinger <vapier@gentoo.org>
Alexey Dobriyan <adobriyan@gmail.com>
linux-kernel@vger.kernel.org
$ ./scripts/get_maintainer.pl -f --noremove-duplicates drivers/char/tty_ioctl.c
Greg Kroah-Hartman <gregkh@suse.de>
Alan Cox <alan@redhat.com>
Alan Cox <alan@linux.intel.com>
Alan Cox <alan@lxorguk.ukuu.org.uk>
Mike Frysinger <vapier@gentoo.org>
Alexey Dobriyan <adobriyan@gmail.com>
linux-kernel@vger.kernel.org
Using --remove-duplicates could eliminate multiple maintainers that
share the same name but not the same email address.
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-x | scripts/get_maintainer.pl | 108 |
1 files changed, 55 insertions, 53 deletions
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl index 446803efe620..473b6741d55f 100755 --- a/scripts/get_maintainer.pl +++ b/scripts/get_maintainer.pl | |||
| @@ -30,6 +30,7 @@ my $email_git_max_maintainers = 5; | |||
| 30 | my $email_git_min_percent = 5; | 30 | my $email_git_min_percent = 5; |
| 31 | my $email_git_since = "1-year-ago"; | 31 | my $email_git_since = "1-year-ago"; |
| 32 | my $email_git_blame = 0; | 32 | my $email_git_blame = 0; |
| 33 | my $email_remove_duplicates = 1; | ||
| 33 | my $output_multiline = 1; | 34 | my $output_multiline = 1; |
| 34 | my $output_separator = ", "; | 35 | my $output_separator = ", "; |
| 35 | my $scm = 0; | 36 | my $scm = 0; |
| @@ -71,6 +72,7 @@ if (!GetOptions( | |||
| 71 | 'git-min-percent=i' => \$email_git_min_percent, | 72 | 'git-min-percent=i' => \$email_git_min_percent, |
| 72 | 'git-since=s' => \$email_git_since, | 73 | 'git-since=s' => \$email_git_since, |
| 73 | 'git-blame!' => \$email_git_blame, | 74 | 'git-blame!' => \$email_git_blame, |
| 75 | 'remove-duplicates!' => \$email_remove_duplicates, | ||
| 74 | 'm!' => \$email_maintainer, | 76 | 'm!' => \$email_maintainer, |
| 75 | 'n!' => \$email_usename, | 77 | 'n!' => \$email_usename, |
| 76 | 'l!' => \$email_list, | 78 | 'l!' => \$email_list, |
| @@ -158,32 +160,28 @@ close(MAINT); | |||
| 158 | 160 | ||
| 159 | my %mailmap; | 161 | my %mailmap; |
| 160 | 162 | ||
| 161 | open(MAILMAP, "<${lk_path}.mailmap") || warn "$P: Can't open .mailmap\n"; | 163 | if ($email_remove_duplicates) { |
| 162 | while (<MAILMAP>) { | 164 | open(MAILMAP, "<${lk_path}.mailmap") || warn "$P: Can't open .mailmap\n"; |
| 163 | my $line = $_; | 165 | while (<MAILMAP>) { |
| 166 | my $line = $_; | ||
| 164 | 167 | ||
| 165 | next if ($line =~ m/^\s*#/); | 168 | next if ($line =~ m/^\s*#/); |
| 166 | next if ($line =~ m/^\s*$/); | 169 | next if ($line =~ m/^\s*$/); |
| 167 | 170 | ||
| 168 | my ($name, $address) = parse_email($line); | 171 | my ($name, $address) = parse_email($line); |
| 169 | $line = format_email($name, $address); | 172 | $line = format_email($name, $address); |
| 170 | 173 | ||
| 171 | next if ($line =~ m/^\s*$/); | 174 | next if ($line =~ m/^\s*$/); |
| 172 | 175 | ||
| 173 | if (exists($mailmap{$name})) { | 176 | if (exists($mailmap{$name})) { |
| 174 | my $obj = $mailmap{$name}; | 177 | my $obj = $mailmap{$name}; |
| 175 | push(@$obj, $address); | 178 | push(@$obj, $address); |
| 176 | } else { | 179 | } else { |
| 177 | my @arr = ($address); | 180 | my @arr = ($address); |
| 178 | $mailmap{$name} = \@arr; | 181 | $mailmap{$name} = \@arr; |
| 179 | } | 182 | } |
| 180 | } | ||
| 181 | close(MAILMAP); | ||
| 182 | |||
| 183 | foreach my $name (sort {$mailmap{$a} <=> $mailmap{$b}} keys %mailmap) { | ||
| 184 | my $obj = $mailmap{$name}; | ||
| 185 | foreach my $address (@$obj) { | ||
| 186 | } | 183 | } |
| 184 | close(MAILMAP); | ||
| 187 | } | 185 | } |
| 188 | 186 | ||
| 189 | ## use the filenames on the command line or find the filenames in the patchfiles | 187 | ## use the filenames on the command line or find the filenames in the patchfiles |
| @@ -373,6 +371,7 @@ MAINTAINER field selection options: | |||
| 373 | --n => include name 'Full Name <addr\@domain.tld>' | 371 | --n => include name 'Full Name <addr\@domain.tld>' |
| 374 | --l => include list(s) if any | 372 | --l => include list(s) if any |
| 375 | --s => include subscriber only list(s) if any | 373 | --s => include subscriber only list(s) if any |
| 374 | --remove-duplicates => minimize duplicate email names/addresses | ||
| 376 | --scm => print SCM tree(s) if any | 375 | --scm => print SCM tree(s) if any |
| 377 | --status => print status if any | 376 | --status => print status if any |
| 378 | --subsystem => print subsystem name if any | 377 | --subsystem => print subsystem name if any |
| @@ -389,7 +388,7 @@ Other options: | |||
| 389 | --help => show this help information | 388 | --help => show this help information |
| 390 | 389 | ||
| 391 | Default options: | 390 | Default options: |
| 392 | [--email --git --m --n --l --multiline --pattern-depth=0] | 391 | [--email --git --m --n --l --multiline --pattern-depth=0 --remove-duplicates] |
| 393 | 392 | ||
| 394 | Notes: | 393 | Notes: |
| 395 | Using "-f directory" may give unexpected results: | 394 | Using "-f directory" may give unexpected results: |
| @@ -438,12 +437,12 @@ sub parse_email { | |||
| 438 | my $name = ""; | 437 | my $name = ""; |
| 439 | my $address = ""; | 438 | my $address = ""; |
| 440 | 439 | ||
| 441 | if ($formatted_email =~ /^([^<]+)<(.*\@.*)>.*$/) { | 440 | if ($formatted_email =~ /^([^<]+)<(.+\@.*)>.*$/) { |
| 442 | $name = $1; | 441 | $name = $1; |
| 443 | $address = $2; | 442 | $address = $2; |
| 444 | } elsif ($formatted_email =~ /^\s*<(.*\@.*)>.*$/) { | 443 | } elsif ($formatted_email =~ /^\s*<(.+\@\S*)>.*$/) { |
| 445 | $address = $1; | 444 | $address = $1; |
| 446 | } elsif ($formatted_email =~ /^\s*(.*\@.*)$/) { | 445 | } elsif ($formatted_email =~ /^(.+\@\S*)$/) { |
| 447 | $address = $1; | 446 | $address = $1; |
| 448 | } | 447 | } |
| 449 | 448 | ||
| @@ -542,14 +541,16 @@ sub add_categories { | |||
| 542 | } | 541 | } |
| 543 | } | 542 | } |
| 544 | 543 | ||
| 545 | sub email_address_inuse { | 544 | my %email_hash_name; |
| 546 | my ($test_address) = @_; | 545 | my %email_hash_address; |
| 547 | 546 | ||
| 548 | foreach my $line (@email_to) { | 547 | sub email_inuse { |
| 549 | my ($name, $address) = parse_email($line); | 548 | my ($name, $address) = @_; |
| 549 | |||
| 550 | return 1 if (($name eq "") && ($address eq "")); | ||
| 551 | return 1 if (($name ne "") && exists($email_hash_name{$name})); | ||
| 552 | return 1 if (($address ne "") && exists($email_hash_address{$address})); | ||
| 550 | 553 | ||
| 551 | return 1 if ($address eq $test_address); | ||
| 552 | } | ||
| 553 | return 0; | 554 | return 0; |
| 554 | } | 555 | } |
| 555 | 556 | ||
| @@ -558,8 +559,12 @@ sub push_email_address { | |||
| 558 | 559 | ||
| 559 | my ($name, $address) = parse_email($line); | 560 | my ($name, $address) = parse_email($line); |
| 560 | 561 | ||
| 561 | if (!email_address_inuse($address)) { | 562 | if (!$email_remove_duplicates) { |
| 563 | push(@email_to, format_email($name, $address)); | ||
| 564 | } elsif (!email_inuse($name, $address)) { | ||
| 562 | push(@email_to, format_email($name, $address)); | 565 | push(@email_to, format_email($name, $address)); |
| 566 | $email_hash_name{$name}++; | ||
| 567 | $email_hash_address{$address}++; | ||
| 563 | } | 568 | } |
| 564 | } | 569 | } |
| 565 | 570 | ||
| @@ -600,6 +605,9 @@ sub mailmap { | |||
| 600 | my ($name, $address) = parse_email($line); | 605 | my ($name, $address) = parse_email($line); |
| 601 | if (!exists($hash{$name})) { | 606 | if (!exists($hash{$name})) { |
| 602 | $hash{$name} = $address; | 607 | $hash{$name} = $address; |
| 608 | } elsif ($address ne $hash{$name}) { | ||
| 609 | $address = $hash{$name}; | ||
| 610 | $line = format_email($name, $address); | ||
| 603 | } | 611 | } |
| 604 | if (exists($mailmap{$name})) { | 612 | if (exists($mailmap{$name})) { |
| 605 | my $obj = $mailmap{$name}; | 613 | my $obj = $mailmap{$name}; |
| @@ -652,31 +660,23 @@ sub recent_git_signoffs { | |||
| 652 | 660 | ||
| 653 | $total_sign_offs = @lines; | 661 | $total_sign_offs = @lines; |
| 654 | 662 | ||
| 655 | @lines = mailmap(@lines); | 663 | if ($email_remove_duplicates) { |
| 664 | @lines = mailmap(@lines); | ||
| 665 | } | ||
| 656 | 666 | ||
| 657 | @lines = sort(@lines); | 667 | @lines = sort(@lines); |
| 668 | |||
| 658 | # uniq -c | 669 | # uniq -c |
| 659 | foreach my $line (@lines) { | 670 | $hash{$_}++ for @lines; |
| 660 | $hash{$line}++; | 671 | |
| 661 | } | ||
| 662 | # sort -rn | 672 | # sort -rn |
| 663 | @lines = (); | ||
| 664 | foreach my $line (sort {$hash{$b} <=> $hash{$a}} keys %hash) { | 673 | foreach my $line (sort {$hash{$b} <=> $hash{$a}} keys %hash) { |
| 665 | push(@lines,"$hash{$line} $line"); | 674 | my $sign_offs = $hash{$line}; |
| 666 | } | 675 | $count++; |
| 667 | 676 | last if ($sign_offs < $email_git_min_signatures || | |
| 668 | foreach my $line (@lines) { | 677 | $count > $email_git_max_maintainers || |
| 669 | if ($line =~ m/([0-9]+)\s+(.*)/) { | 678 | $sign_offs * 100 / $total_sign_offs < $email_git_min_percent); |
| 670 | my $sign_offs = $1; | 679 | push_email_address($line); |
| 671 | $line = $2; | ||
| 672 | $count++; | ||
| 673 | if ($sign_offs < $email_git_min_signatures || | ||
| 674 | $count > $email_git_max_maintainers || | ||
| 675 | $sign_offs * 100 / $total_sign_offs < $email_git_min_percent) { | ||
| 676 | last; | ||
| 677 | } | ||
| 678 | push_email_address($line); | ||
| 679 | } | ||
| 680 | } | 680 | } |
| 681 | } | 681 | } |
| 682 | 682 | ||
| @@ -743,7 +743,9 @@ sub git_assign_blame { | |||
| 743 | 743 | ||
| 744 | $total_sign_offs += @lines; | 744 | $total_sign_offs += @lines; |
| 745 | 745 | ||
| 746 | @lines = mailmap(@lines); | 746 | if ($email_remove_duplicates) { |
| 747 | @lines = mailmap(@lines); | ||
| 748 | } | ||
| 747 | 749 | ||
| 748 | $hash{$_}++ for @lines; | 750 | $hash{$_}++ for @lines; |
| 749 | } | 751 | } |
