Skip to content

Commit 71ca5ee

Browse files
JoePerchesakpm00
authored andcommitted
get_maintainer: add --keywords-in-file option
There were some recent attempts [1] [2] to make the K: field less noisy and its behavior more obvious. Ultimately, a shift in the default behavior and an associated command line flag is the best choice. Currently, K: will match keywords found in both patches and files. Matching content from entire files is (while documented) not obvious behavior and is usually not wanted by maintainers. Now only patch content will be matched against unless --keywords-in-file is also provided as an argument to get_maintainer. Add the actual keyword matched to the role or rolestats as well. For instance given the diff below that removes clang: : diff --git a/drivers/hid/bpf/entrypoints/README b/drivers/hid/bpf/entrypoints/README : index 147e0d4..f88eb19e8ef2 100644 : --- a/drivers/hid/bpf/entrypoints/README : +++ b/drivers/hid/bpf/entrypoints/README : @@ -1,4 +1,4 @@ : WARNING: : If you change "entrypoints.bpf.c" do "make -j" in this directory to rebuild "entrypoints.skel.h". : -Make sure to have clang 10 installed. : +Make sure to have 10 installed. : See Documentation/bpf/bpf_devel_QA.rst The new role/rolestats output includes ":Keyword:\b(?i:clang|llvm)\b" $ git diff drivers/hid/bpf/entrypoints/README | .scripts/get_maintainer.pl Jiri Kosina <[email protected]> (maintainer:HID CORE LAYER,commit_signer:1/1=100%) Benjamin Tissoires <[email protected]> (maintainer:HID CORE LAYER,commit_signer:1/1=100%,authored:1/1=100%,added_lines:4/4=100%) Nathan Chancellor <[email protected]> (supporter:CLANG/LLVM BUILD SUPPORT:Keyword:\b(?i:clang|llvm)\b) Nick Desaulniers <[email protected]> (supporter:CLANG/LLVM BUILD SUPPORT:Keyword:\b(?i:clang|llvm)\b) Tom Rix <[email protected]> (reviewer:CLANG/LLVM BUILD SUPPORT:Keyword:\b(?i:clang|llvm)\b) Greg Kroah-Hartman <[email protected]> (commit_signer:1/1=100%) [email protected] (open list:HID CORE LAYER) [email protected] (open list) [email protected] (open list:CLANG/LLVM BUILD SUPPORT:Keyword:\b(?i:clang|llvm)\b) Link: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/all/[email protected] Link: https://lore.kernel.org/all/[email protected] Original-patch-by: Justin Stitt <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Joe Perches <[email protected]> Tested-by: Justin Stitt <[email protected]> Cc: Kees Cook <[email protected]> Cc: Nick Desaulniers <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent ead5a72 commit 71ca5ee

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

scripts/get_maintainer.pl

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
my $status = 0;
5858
my $letters = "";
5959
my $keywords = 1;
60+
my $keywords_in_file = 0;
6061
my $sections = 0;
6162
my $email_file_emails = 0;
6263
my $from_filename = 0;
@@ -272,6 +273,7 @@
272273
'letters=s' => \$letters,
273274
'pattern-depth=i' => \$pattern_depth,
274275
'k|keywords!' => \$keywords,
276+
'kf|keywords-in-file!' => \$keywords_in_file,
275277
'sections!' => \$sections,
276278
'fe|file-emails!' => \$email_file_emails,
277279
'f|file' => \$from_filename,
@@ -318,6 +320,7 @@
318320
$subsystem = 0;
319321
$web = 0;
320322
$keywords = 0;
323+
$keywords_in_file = 0;
321324
$interactive = 0;
322325
} else {
323326
my $selections = $email + $scm + $status + $subsystem + $web;
@@ -548,16 +551,14 @@ sub read_mailmap {
548551
$file =~ s/^\Q${cur_path}\E//; #strip any absolute path
549552
$file =~ s/^\Q${lk_path}\E//; #or the path to the lk tree
550553
push(@files, $file);
551-
if ($file ne "MAINTAINERS" && -f $file && $keywords) {
554+
if ($file ne "MAINTAINERS" && -f $file && $keywords && $keywords_in_file) {
552555
open(my $f, '<', $file)
553556
or die "$P: Can't open $file: $!\n";
554557
my $text = do { local($/) ; <$f> };
555558
close($f);
556-
if ($keywords) {
557-
foreach my $line (keys %keyword_hash) {
558-
if ($text =~ m/$keyword_hash{$line}/x) {
559-
push(@keyword_tvi, $line);
560-
}
559+
foreach my $line (keys %keyword_hash) {
560+
if ($text =~ m/$keyword_hash{$line}/x) {
561+
push(@keyword_tvi, $line);
561562
}
562563
}
563564
}
@@ -919,7 +920,7 @@ sub get_maintainers {
919920
}
920921

921922
foreach my $line (sort {$hash{$b} <=> $hash{$a}} keys %hash) {
922-
add_categories($line);
923+
add_categories($line, "");
923924
if ($sections) {
924925
my $i;
925926
my $start = find_starting_index($line);
@@ -947,7 +948,7 @@ sub get_maintainers {
947948
if ($keywords) {
948949
@keyword_tvi = sort_and_uniq(@keyword_tvi);
949950
foreach my $line (@keyword_tvi) {
950-
add_categories($line);
951+
add_categories($line, ":Keyword:$keyword_hash{$line}");
951952
}
952953
}
953954

@@ -1076,6 +1077,7 @@ sub usage {
10761077
Other options:
10771078
--pattern-depth => Number of pattern directory traversals (default: 0 (all))
10781079
--keywords => scan patch for keywords (default: $keywords)
1080+
--keywords-in-file => scan file for keywords (default: $keywords_in_file)
10791081
--sections => print all of the subsystem sections with pattern matches
10801082
--letters => print all matching 'letter' types from all matching sections
10811083
--mailmap => use .mailmap file (default: $email_use_mailmap)
@@ -1086,7 +1088,7 @@ sub usage {
10861088
10871089
Default options:
10881090
[--email --tree --nogit --git-fallback --m --r --n --l --multiline
1089-
--pattern-depth=0 --remove-duplicates --rolestats]
1091+
--pattern-depth=0 --remove-duplicates --rolestats --keywords]
10901092
10911093
Notes:
10921094
Using "-f directory" may give unexpected results:
@@ -1312,7 +1314,7 @@ sub get_list_role {
13121314
}
13131315

13141316
sub add_categories {
1315-
my ($index) = @_;
1317+
my ($index, $suffix) = @_;
13161318

13171319
my $i;
13181320
my $start = find_starting_index($index);
@@ -1342,7 +1344,7 @@ sub add_categories {
13421344
if (!$hash_list_to{lc($list_address)}) {
13431345
$hash_list_to{lc($list_address)} = 1;
13441346
push(@list_to, [$list_address,
1345-
"subscriber list${list_role}"]);
1347+
"subscriber list${list_role}" . $suffix]);
13461348
}
13471349
}
13481350
} else {
@@ -1352,32 +1354,32 @@ sub add_categories {
13521354
if ($email_moderated_list) {
13531355
$hash_list_to{lc($list_address)} = 1;
13541356
push(@list_to, [$list_address,
1355-
"moderated list${list_role}"]);
1357+
"moderated list${list_role}" . $suffix]);
13561358
}
13571359
} else {
13581360
$hash_list_to{lc($list_address)} = 1;
13591361
push(@list_to, [$list_address,
1360-
"open list${list_role}"]);
1362+
"open list${list_role}" . $suffix]);
13611363
}
13621364
}
13631365
}
13641366
}
13651367
} elsif ($ptype eq "M") {
13661368
if ($email_maintainer) {
13671369
my $role = get_maintainer_role($i);
1368-
push_email_addresses($pvalue, $role);
1370+
push_email_addresses($pvalue, $role . $suffix);
13691371
}
13701372
} elsif ($ptype eq "R") {
13711373
if ($email_reviewer) {
13721374
my $subsystem = get_subsystem_name($i);
1373-
push_email_addresses($pvalue, "reviewer:$subsystem");
1375+
push_email_addresses($pvalue, "reviewer:$subsystem" . $suffix);
13741376
}
13751377
} elsif ($ptype eq "T") {
1376-
push(@scm, $pvalue);
1378+
push(@scm, $pvalue . $suffix);
13771379
} elsif ($ptype eq "W") {
1378-
push(@web, $pvalue);
1380+
push(@web, $pvalue . $suffix);
13791381
} elsif ($ptype eq "S") {
1380-
push(@status, $pvalue);
1382+
push(@status, $pvalue . $suffix);
13811383
}
13821384
}
13831385
}

0 commit comments

Comments
 (0)