[PATCH] get_maintainer: Add the --for-tree argument
From: Palmer Dabbelt
Date: Thu Oct 13 2022 - 17:58:05 EST
I recently wanted to look up the maintainers for each tree path via a
script, and I couldn't find a better way to do that than poking
get_maintainer.pl to add a new argument. This lets folks run something
like
$ ./scripts/get_maintainer.pl --for-tree git://github.com/kvm-riscv/linux.git
Anup Patel <anup@xxxxxxxxxxxxxx> (maintainer:KERNEL VIRTUAL MACHINE FOR RISC-V (KVM/riscv))
kvm@xxxxxxxxxxxxxxx (maintainer:KERNEL VIRTUAL MACHINE FOR RISC-V (KVM/riscv))
kvm-riscv@xxxxxxxxxxxxxxxxxxx (maintainer:KERNEL VIRTUAL MACHINE FOR RISC-V (KVM/riscv))
linux-riscv@xxxxxxxxxxxxxxxxxxx (maintainer:KERNEL VIRTUAL MACHINE FOR RISC-V (KVM/riscv))
to find out who owns a tree.
Signed-off-by: Palmer Dabbelt <palmer@xxxxxxxxxxxx>
---
scripts/get_maintainer.pl | 48 +++++++++++++++++++++++++++++++++++++--
1 file changed, 46 insertions(+), 2 deletions(-)
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index ab123b498fd9..70abefadd295 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -23,6 +23,7 @@ use File::Spec::Functions;
my $cur_path = fastgetcwd() . '/';
my $lk_path = "./";
+my $for_tree = undef;
my $email = 1;
my $email_usename = 1;
my $email_maintainer = 1;
@@ -239,6 +240,7 @@ if ($#ARGV > 0) {
if (!GetOptions(
'email!' => \$email,
+ 'for-tree=s' => \$for_tree,
'git!' => \$email_git,
'git-all-signature-types!' => \$email_git_all_signature_types,
'git-blame!' => \$email_git_blame,
@@ -300,7 +302,7 @@ if (defined $self_test) {
exit 0;
}
-if (-t STDIN && !@ARGV) {
+if (-t STDIN && !@ARGV && !$for_tree) {
# We're talking to a terminal, but have no command line arguments.
die "$P: missing patchfile or -f file - use --help if necessary\n";
}
@@ -527,7 +529,7 @@ sub read_mailmap {
## use the filenames on the command line or find the filenames in the patchfiles
-if (!@ARGV) {
+if (!@ARGV && !$for_tree) {
push(@ARGV, "&STDIN");
}
@@ -951,6 +953,47 @@ sub get_maintainers {
}
}
+ if ($for_tree) {
+ my $tvi = find_first_section();
+ while ($tvi < @typevalue) {
+ my $start = find_starting_index($tvi);
+ my $end = find_ending_index($tvi);
+ $tvi = $end + 1;
+
+ my $i;
+ my $tree_match = 0;
+ for ($i = $start; $i < $end; $i++) {
+ my $line = $typevalue[$i];
+ if ($line =~ m/^([A-Z]):(.*)/) {
+ my $type = $1;
+ my $value = $2;
+
+ if ($type eq 'T') {
+ if ($for_tree eq $value || "git $for_tree" eq $value) {
+ $tree_match = 1
+ }
+ }
+ }
+ }
+
+ if ($tree_match) {
+ for ($i = $start; $i < $end; $i++) {
+ my $line = $typevalue[$i];
+ if ($line =~ m/^([A-Z]):(.*)/) {
+ my $type = $1;
+ my $value = $2;
+
+ if ($type eq 'M' || $type eq 'L') {
+ my $role = get_maintainer_role($i);
+ push_email_address($value, $role)
+ }
+ }
+ }
+ }
+ }
+ }
+
+
foreach my $email (@email_to, @list_to) {
$email->[0] = deduplicate_email($email->[0]);
}
@@ -1074,6 +1117,7 @@ Output type options:
--multiline => print 1 entry per line
Other options:
+ --for-tree => Get maintainers for the given tree
--pattern-depth => Number of pattern directory traversals (default: 0 (all))
--keywords => scan patch for keywords (default: $keywords)
--sections => print all of the subsystem sections with pattern matches
--
2.38.0