scripts/get_maintainer.pl - Allow multiple files on command line
Improve handling of "by:" signoffs Sorting and frequency checks are done by name/email, not by "by:" tag. Signed-off-by: Joe Perches <joe@perches.com>
This commit is contained in:
parent
69aefcead5
commit
4a7fdb5f51
|
@ -13,7 +13,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
my $P = $0;
|
my $P = $0;
|
||||||
my $V = '0.14';
|
my $V = '0.15';
|
||||||
|
|
||||||
use Getopt::Long qw(:config no_auto_abbrev);
|
use Getopt::Long qw(:config no_auto_abbrev);
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ my $scm = 0;
|
||||||
my $web = 0;
|
my $web = 0;
|
||||||
my $subsystem = 0;
|
my $subsystem = 0;
|
||||||
my $status = 0;
|
my $status = 0;
|
||||||
my $onefile = 0;
|
my $from_filename = 0;
|
||||||
my $version = 0;
|
my $version = 0;
|
||||||
my $help = 0;
|
my $help = 0;
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ if (!GetOptions(
|
||||||
'status!' => \$status,
|
'status!' => \$status,
|
||||||
'scm!' => \$scm,
|
'scm!' => \$scm,
|
||||||
'web!' => \$web,
|
'web!' => \$web,
|
||||||
'f|file' => \$onefile,
|
'f|file' => \$from_filename,
|
||||||
'v|version' => \$version,
|
'v|version' => \$version,
|
||||||
'h|help' => \$help,
|
'h|help' => \$help,
|
||||||
)) {
|
)) {
|
||||||
|
@ -90,8 +90,6 @@ if ($version != 0) {
|
||||||
exit 0;
|
exit 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $infile = $ARGV[0];
|
|
||||||
|
|
||||||
if ($#ARGV < 0) {
|
if ($#ARGV < 0) {
|
||||||
usage();
|
usage();
|
||||||
die "$P: argument missing: patchfile or -f file please\n";
|
die "$P: argument missing: patchfile or -f file please\n";
|
||||||
|
@ -139,32 +137,35 @@ while (<MAINT>) {
|
||||||
}
|
}
|
||||||
close(MAINT);
|
close(MAINT);
|
||||||
|
|
||||||
## use the filename on the command line or find the filenames in the patchfile
|
## use the filenames on the command line or find the filenames in the patchfiles
|
||||||
|
|
||||||
my @files = ();
|
my @files = ();
|
||||||
|
|
||||||
if ($onefile) {
|
foreach my $file (@ARGV) {
|
||||||
if (!(-f $infile)) {
|
next if ((-d $file));
|
||||||
die "$P: file '${infile}' not found\n";
|
if (!(-f $file)) {
|
||||||
|
die "$P: file '${file}' not found\n";
|
||||||
}
|
}
|
||||||
push(@files, $infile);
|
if ($from_filename) {
|
||||||
} else {
|
push(@files, $file);
|
||||||
open(PATCH, "<$infile") or die "$P: Can't open ${infile}\n";
|
} else {
|
||||||
while (<PATCH>) {
|
my $file_cnt = @files;
|
||||||
if (m/^\+\+\+\s+(\S+)/) {
|
open(PATCH, "<$file") or die "$P: Can't open ${file}\n";
|
||||||
my $file = $1;
|
while (<PATCH>) {
|
||||||
$file =~ s@^[^/]*/@@;
|
if (m/^\+\+\+\s+(\S+)/) {
|
||||||
$file =~ s@\n@@;
|
my $filename = $1;
|
||||||
push(@files, $file);
|
$filename =~ s@^[^/]*/@@;
|
||||||
|
$filename =~ s@\n@@;
|
||||||
|
push(@files, $filename);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
close(PATCH);
|
||||||
|
if ($file_cnt == @files) {
|
||||||
|
die "$P: file '${file}' doesn't appear to be a patch. "
|
||||||
|
. "Add -f to options?\n";
|
||||||
|
}
|
||||||
|
@files = sort_and_uniq(@files);
|
||||||
}
|
}
|
||||||
close(PATCH);
|
|
||||||
my $file_cnt = @files;
|
|
||||||
if ($file_cnt == 0) {
|
|
||||||
print STDERR "$P: file '${infile}' doesn't appear to be a patch. "
|
|
||||||
. "Add -f to options?\n";
|
|
||||||
}
|
|
||||||
@files = sort_and_uniq(@files);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my @email_to = ();
|
my @email_to = ();
|
||||||
|
@ -208,7 +209,7 @@ foreach my $file (@files) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($email_git) {
|
if ($email && $email_git) {
|
||||||
recent_git_signoffs($file);
|
recent_git_signoffs($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,30 +241,22 @@ if ($email) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($scm) {
|
if ($scm) {
|
||||||
if (!$onefile) {
|
@scm = sort_and_uniq(@scm);
|
||||||
@scm = sort_and_uniq(@scm);
|
|
||||||
}
|
|
||||||
output(@scm);
|
output(@scm);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($status) {
|
if ($status) {
|
||||||
if (!$onefile) {
|
@status = sort_and_uniq(@status);
|
||||||
@status = sort_and_uniq(@status);
|
|
||||||
}
|
|
||||||
output(@status);
|
output(@status);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($subsystem) {
|
if ($subsystem) {
|
||||||
if (!$onefile) {
|
@subsystem = sort_and_uniq(@subsystem);
|
||||||
@subsystem = sort_and_uniq(@subsystem);
|
|
||||||
}
|
|
||||||
output(@subsystem);
|
output(@subsystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($web) {
|
if ($web) {
|
||||||
if (!$onefile) {
|
@web = sort_and_uniq(@web);
|
||||||
@web = sort_and_uniq(@web);
|
|
||||||
}
|
|
||||||
output(@web);
|
output(@web);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,10 +438,12 @@ sub recent_git_signoffs {
|
||||||
}
|
}
|
||||||
|
|
||||||
$cmd = "git log --since=${email_git_since} -- ${file}";
|
$cmd = "git log --since=${email_git_since} -- ${file}";
|
||||||
$cmd .= " | grep -P '^ [-A-Za-z]+by:.*\\\@'";
|
$cmd .= " | grep -Pi \"^[-_ a-z]+by:.*\\\@\"";
|
||||||
if (!$email_git_penguin_chiefs) {
|
if (!$email_git_penguin_chiefs) {
|
||||||
$cmd .= " | grep -E -v \"${penguin_chiefs}\"";
|
$cmd .= " | grep -Pv \"${penguin_chiefs}\"";
|
||||||
}
|
}
|
||||||
|
$cmd .= " | cut -f2- -d\":\"";
|
||||||
|
$cmd .= " | sed -e \"s/^\\s+//g\"";
|
||||||
$cmd .= " | sort | uniq -c | sort -rn";
|
$cmd .= " | sort | uniq -c | sort -rn";
|
||||||
|
|
||||||
$output = `${cmd}`;
|
$output = `${cmd}`;
|
||||||
|
@ -456,9 +451,9 @@ sub recent_git_signoffs {
|
||||||
|
|
||||||
@lines = split("\n", $output);
|
@lines = split("\n", $output);
|
||||||
foreach my $line (@lines) {
|
foreach my $line (@lines) {
|
||||||
if ($line =~ m/([0-9]+)\s+([-A-Za-z]+by:)\s+(.*)/) {
|
if ($line =~ m/([0-9]+)\s+(.*)/) {
|
||||||
my $sign_offs = $1;
|
my $sign_offs = $1;
|
||||||
$line = $3;
|
$line = $2;
|
||||||
$count++;
|
$count++;
|
||||||
if ($sign_offs < $email_git_min_signatures ||
|
if ($sign_offs < $email_git_min_signatures ||
|
||||||
$count > $email_git_max_maintainers) {
|
$count > $email_git_max_maintainers) {
|
||||||
|
@ -467,17 +462,19 @@ sub recent_git_signoffs {
|
||||||
} else {
|
} else {
|
||||||
die("$P: Unexpected git output: ${line}\n");
|
die("$P: Unexpected git output: ${line}\n");
|
||||||
}
|
}
|
||||||
if ($line =~ m/(.*) <(.*)>/) {
|
if ($line =~ m/(.+)<(.+)>/) {
|
||||||
my $git_name = $1;
|
my $git_name = $1;
|
||||||
my $git_addr = $2;
|
my $git_addr = $2;
|
||||||
$git_name =~ tr/^\"//;
|
$git_name =~ tr/^\"//;
|
||||||
|
$git_name =~ tr/^\\s*//;
|
||||||
$git_name =~ tr/\"$//;
|
$git_name =~ tr/\"$//;
|
||||||
|
$git_name =~ tr/\\s*$//;
|
||||||
if ($email_usename) {
|
if ($email_usename) {
|
||||||
push(@email_to, format_email($git_name, $git_addr));
|
push(@email_to, format_email($git_name, $git_addr));
|
||||||
} else {
|
} else {
|
||||||
push(@email_to, $git_addr);
|
push(@email_to, $git_addr);
|
||||||
}
|
}
|
||||||
} elsif ($line =~ m/<(.*)>/) {
|
} elsif ($line =~ m/<(.+)>/) {
|
||||||
my $git_addr = $1;
|
my $git_addr = $1;
|
||||||
push(@email_to, $git_addr);
|
push(@email_to, $git_addr);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue