aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/get_maintainer.pl85
1 files changed, 41 insertions, 44 deletions
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index 0f3c0a5b5a5b..60dc0c48c929 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -13,7 +13,7 @@
13use strict; 13use strict;
14 14
15my $P = $0; 15my $P = $0;
16my $V = '0.14'; 16my $V = '0.15';
17 17
18use Getopt::Long qw(:config no_auto_abbrev); 18use Getopt::Long qw(:config no_auto_abbrev);
19 19
@@ -34,7 +34,7 @@ my $scm = 0;
34my $web = 0; 34my $web = 0;
35my $subsystem = 0; 35my $subsystem = 0;
36my $status = 0; 36my $status = 0;
37my $onefile = 0; 37my $from_filename = 0;
38my $version = 0; 38my $version = 0;
39my $help = 0; 39my $help = 0;
40 40
@@ -72,7 +72,7 @@ if (!GetOptions(
72 'status!' => \$status, 72 'status!' => \$status,
73 'scm!' => \$scm, 73 'scm!' => \$scm,
74 'web!' => \$web, 74 'web!' => \$web,
75 'f|file' => \$onefile, 75 'f|file' => \$from_filename,
76 'v|version' => \$version, 76 'v|version' => \$version,
77 'h|help' => \$help, 77 'h|help' => \$help,
78 )) { 78 )) {
@@ -90,8 +90,6 @@ if ($version != 0) {
90 exit 0; 90 exit 0;
91} 91}
92 92
93my $infile = $ARGV[0];
94
95if ($#ARGV < 0) { 93if ($#ARGV < 0) {
96 usage(); 94 usage();
97 die "$P: argument missing: patchfile or -f file please\n"; 95 die "$P: argument missing: patchfile or -f file please\n";
@@ -139,32 +137,35 @@ while (<MAINT>) {
139} 137}
140close(MAINT); 138close(MAINT);
141 139
142## use the filename on the command line or find the filenames in the patchfile 140## use the filenames on the command line or find the filenames in the patchfiles
143 141
144my @files = (); 142my @files = ();
145 143
146if ($onefile) { 144foreach my $file (@ARGV) {
147 if (!(-f $infile)) { 145 next if ((-d $file));
148 die "$P: file '${infile}' not found\n"; 146 if (!(-f $file)) {
147 die "$P: file '${file}' not found\n";
149 } 148 }
150 push(@files, $infile); 149 if ($from_filename) {
151} else { 150 push(@files, $file);
152 open(PATCH, "<$infile") or die "$P: Can't open ${infile}\n"; 151 } else {
153 while (<PATCH>) { 152 my $file_cnt = @files;
154 if (m/^\+\+\+\s+(\S+)/) { 153 open(PATCH, "<$file") or die "$P: Can't open ${file}\n";
155 my $file = $1; 154 while (<PATCH>) {
156 $file =~ s@^[^/]*/@@; 155 if (m/^\+\+\+\s+(\S+)/) {
157 $file =~ s@\n@@; 156 my $filename = $1;
158 push(@files, $file); 157 $filename =~ s@^[^/]*/@@;
158 $filename =~ s@\n@@;
159 push(@files, $filename);
160 }
159 } 161 }
162 close(PATCH);
163 if ($file_cnt == @files) {
164 die "$P: file '${file}' doesn't appear to be a patch. "
165 . "Add -f to options?\n";
166 }
167 @files = sort_and_uniq(@files);
160 } 168 }
161 close(PATCH);
162 my $file_cnt = @files;
163 if ($file_cnt == 0) {
164 print STDERR "$P: file '${infile}' doesn't appear to be a patch. "
165 . "Add -f to options?\n";
166 }
167 @files = sort_and_uniq(@files);
168} 169}
169 170
170my @email_to = (); 171my @email_to = ();
@@ -208,7 +209,7 @@ foreach my $file (@files) {
208 } 209 }
209 } 210 }
210 211
211 if ($email_git) { 212 if ($email && $email_git) {
212 recent_git_signoffs($file); 213 recent_git_signoffs($file);
213 } 214 }
214 215
@@ -240,30 +241,22 @@ if ($email) {
240} 241}
241 242
242if ($scm) { 243if ($scm) {
243 if (!$onefile) { 244 @scm = sort_and_uniq(@scm);
244 @scm = sort_and_uniq(@scm);
245 }
246 output(@scm); 245 output(@scm);
247} 246}
248 247
249if ($status) { 248if ($status) {
250 if (!$onefile) { 249 @status = sort_and_uniq(@status);
251 @status = sort_and_uniq(@status);
252 }
253 output(@status); 250 output(@status);
254} 251}
255 252
256if ($subsystem) { 253if ($subsystem) {
257 if (!$onefile) { 254 @subsystem = sort_and_uniq(@subsystem);
258 @subsystem = sort_and_uniq(@subsystem);
259 }
260 output(@subsystem); 255 output(@subsystem);
261} 256}
262 257
263if ($web) { 258if ($web) {
264 if (!$onefile) { 259 @web = sort_and_uniq(@web);
265 @web = sort_and_uniq(@web);
266 }
267 output(@web); 260 output(@web);
268} 261}
269 262
@@ -445,10 +438,12 @@ sub recent_git_signoffs {
445 } 438 }
446 439
447 $cmd = "git log --since=${email_git_since} -- ${file}"; 440 $cmd = "git log --since=${email_git_since} -- ${file}";
448 $cmd .= " | grep -P '^ [-A-Za-z]+by:.*\\\@'"; 441 $cmd .= " | grep -Pi \"^[-_ a-z]+by:.*\\\@\"";
449 if (!$email_git_penguin_chiefs) { 442 if (!$email_git_penguin_chiefs) {
450 $cmd .= " | grep -E -v \"${penguin_chiefs}\""; 443 $cmd .= " | grep -Pv \"${penguin_chiefs}\"";
451 } 444 }
445 $cmd .= " | cut -f2- -d\":\"";
446 $cmd .= " | sed -e \"s/^\\s+//g\"";
452 $cmd .= " | sort | uniq -c | sort -rn"; 447 $cmd .= " | sort | uniq -c | sort -rn";
453 448
454 $output = `${cmd}`; 449 $output = `${cmd}`;
@@ -456,9 +451,9 @@ sub recent_git_signoffs {
456 451
457 @lines = split("\n", $output); 452 @lines = split("\n", $output);
458 foreach my $line (@lines) { 453 foreach my $line (@lines) {
459 if ($line =~ m/([0-9]+)\s+([-A-Za-z]+by:)\s+(.*)/) { 454 if ($line =~ m/([0-9]+)\s+(.*)/) {
460 my $sign_offs = $1; 455 my $sign_offs = $1;
461 $line = $3; 456 $line = $2;
462 $count++; 457 $count++;
463 if ($sign_offs < $email_git_min_signatures || 458 if ($sign_offs < $email_git_min_signatures ||
464 $count > $email_git_max_maintainers) { 459 $count > $email_git_max_maintainers) {
@@ -467,17 +462,19 @@ sub recent_git_signoffs {
467 } else { 462 } else {
468 die("$P: Unexpected git output: ${line}\n"); 463 die("$P: Unexpected git output: ${line}\n");
469 } 464 }
470 if ($line =~ m/(.*) <(.*)>/) { 465 if ($line =~ m/(.+)<(.+)>/) {
471 my $git_name = $1; 466 my $git_name = $1;
472 my $git_addr = $2; 467 my $git_addr = $2;
473 $git_name =~ tr/^\"//; 468 $git_name =~ tr/^\"//;
469 $git_name =~ tr/^\\s*//;
474 $git_name =~ tr/\"$//; 470 $git_name =~ tr/\"$//;
471 $git_name =~ tr/\\s*$//;
475 if ($email_usename) { 472 if ($email_usename) {
476 push(@email_to, format_email($git_name, $git_addr)); 473 push(@email_to, format_email($git_name, $git_addr));
477 } else { 474 } else {
478 push(@email_to, $git_addr); 475 push(@email_to, $git_addr);
479 } 476 }
480 } elsif ($line =~ m/<(.*)>/) { 477 } elsif ($line =~ m/<(.+)>/) {
481 my $git_addr = $1; 478 my $git_addr = $1;
482 push(@email_to, $git_addr); 479 push(@email_to, $git_addr);
483 } else { 480 } else {