lkml.org 
[lkml]   [2022]   [Oct]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH] get_maintainer: Add the --for-tree argument
Date
From
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
\
 
 \ /
  Last update: 2022-10-13 23:59    [W:0.081 / U:0.472 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site