lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 13 Oct 2022 14:57:38 -0700
From:   Palmer Dabbelt <palmer@...osinc.com>
To:     joe@...ches.com
Cc:        linux-kernel@...r.kernel.org,
           Palmer Dabbelt <palmer@...osinc.com>
Subject: [PATCH] get_maintainer: Add the --for-tree argument

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

to find out who owns a tree.

Signed-off-by: Palmer Dabbelt <palmer@...osinc.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 && !@...V) {
+if (-t STDIN && !@...V && !$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 (!@...V) {
+if (!@...V && !$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

Powered by blists - more mailing lists