mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] get_maintainer: Add the --for-tree argument
@ 2022-10-13 21:57 Palmer Dabbelt
  2022-10-14  0:39 ` Joe Perches
  0 siblings, 1 reply; 5+ messages in thread
From: Palmer Dabbelt @ 2022-10-13 21:57 UTC (permalink / raw)
  To: joe; +Cc: linux-kernel, Palmer Dabbelt

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@brainfault.org> (maintainer:KERNEL VIRTUAL MACHINE FOR RISC-V (KVM/riscv))
    kvm@vger.kernel.org (maintainer:KERNEL VIRTUAL MACHINE FOR RISC-V (KVM/riscv))
    kvm-riscv@lists.infradead.org (maintainer:KERNEL VIRTUAL MACHINE FOR RISC-V (KVM/riscv))
    linux-riscv@lists.infradead.org (maintainer:KERNEL VIRTUAL MACHINE FOR RISC-V (KVM/riscv))

to find out who owns a tree.

Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
---
 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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-10-14  3:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-13 21:57 [PATCH] get_maintainer: Add the --for-tree argument Palmer Dabbelt
2022-10-14  0:39 ` Joe Perches
2022-10-14  2:56   ` Palmer Dabbelt
2022-10-14  3:48     ` Joe Perches
2022-10-14  3:52       ` Palmer Dabbelt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®