hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/scripts/get_maintainer.pl
....@@ -19,6 +19,7 @@
1919 use Getopt::Long qw(:config no_auto_abbrev);
2020 use Cwd;
2121 use File::Find;
22
+use File::Spec::Functions;
2223
2324 my $cur_path = fastgetcwd() . '/';
2425 my $lk_path = "./";
....@@ -26,7 +27,9 @@
2627 my $email_usename = 1;
2728 my $email_maintainer = 1;
2829 my $email_reviewer = 1;
30
+my $email_fixes = 1;
2931 my $email_list = 1;
32
+my $email_moderated_list = 1;
3033 my $email_subscriber_list = 0;
3134 my $email_git_penguin_chiefs = 0;
3235 my $email_git = 0;
....@@ -55,7 +58,7 @@
5558 my $letters = "";
5659 my $keywords = 1;
5760 my $sections = 0;
58
-my $file_emails = 0;
61
+my $email_file_emails = 0;
5962 my $from_filename = 0;
6063 my $pattern_depth = 0;
6164 my $self_test = undef;
....@@ -66,6 +69,12 @@
6669 my $vcs_used = 0;
6770
6871 my $exit = 0;
72
+
73
+my @files = ();
74
+my @fixes = (); # If a patch description includes Fixes: lines
75
+my @range = ();
76
+my @keyword_tvi = ();
77
+my @file_emails = ();
6978
7079 my %commit_author_hash;
7180 my %commit_signer_hash;
....@@ -248,6 +257,8 @@
248257 'r!' => \$email_reviewer,
249258 'n!' => \$email_usename,
250259 'l!' => \$email_list,
260
+ 'fixes!' => \$email_fixes,
261
+ 'moderated!' => \$email_moderated_list,
251262 's!' => \$email_subscriber_list,
252263 'multiline!' => \$output_multiline,
253264 'roles!' => \$output_roles,
....@@ -262,7 +273,7 @@
262273 'pattern-depth=i' => \$pattern_depth,
263274 'k|keywords!' => \$keywords,
264275 'sections!' => \$sections,
265
- 'fe|file-emails!' => \$file_emails,
276
+ 'fe|file-emails!' => \$email_file_emails,
266277 'f|file' => \$from_filename,
267278 'find-maintainer-files' => \$find_maintainer_files,
268279 'mpath|maintainer-path=s' => \$maintainer_path,
....@@ -420,6 +431,22 @@
420431 }
421432 }
422433
434
+sub maintainers_in_file {
435
+ my ($file) = @_;
436
+
437
+ return if ($file =~ m@\bMAINTAINERS$@);
438
+
439
+ if (-f $file && ($email_file_emails || $file =~ /\.yaml$/)) {
440
+ open(my $f, '<', $file)
441
+ or die "$P: Can't open $file: $!\n";
442
+ my $text = do { local($/) ; <$f> };
443
+ close($f);
444
+
445
+ my @poss_addr = $text =~ m$[A-Za-zÀ-ÿ\"\' \,\.\+-]*\s*[\,]*\s*[\(\<\{]{0,1}[A-Za-z0-9_\.\+-]+\@[A-Za-z0-9\.-]+\.[A-Za-z0-9]+[\)\>\}]{0,1}$g;
446
+ push(@file_emails, clean_file_emails(@poss_addr));
447
+ }
448
+}
449
+
423450 #
424451 # Read mail address map
425452 #
....@@ -500,17 +527,13 @@
500527
501528 ## use the filenames on the command line or find the filenames in the patchfiles
502529
503
-my @files = ();
504
-my @range = ();
505
-my @keyword_tvi = ();
506
-my @file_emails = ();
507
-
508530 if (!@ARGV) {
509531 push(@ARGV, "&STDIN");
510532 }
511533
512534 foreach my $file (@ARGV) {
513535 if ($file ne "&STDIN") {
536
+ $file = canonpath($file);
514537 ##if $file is a directory and it lacks a trailing slash, add one
515538 if ((-d $file)) {
516539 $file =~ s@([^/])$@$1/@;
....@@ -518,11 +541,14 @@
518541 die "$P: file '${file}' not found\n";
519542 }
520543 }
544
+ if ($from_filename && (vcs_exists() && !vcs_file_exists($file))) {
545
+ warn "$P: file '$file' not found in version control $!\n";
546
+ }
521547 if ($from_filename || ($file ne "&STDIN" && vcs_file_exists($file))) {
522548 $file =~ s/^\Q${cur_path}\E//; #strip any absolute path
523549 $file =~ s/^\Q${lk_path}\E//; #or the path to the lk tree
524550 push(@files, $file);
525
- if ($file ne "MAINTAINERS" && -f $file && ($keywords || $file_emails)) {
551
+ if ($file ne "MAINTAINERS" && -f $file && $keywords) {
526552 open(my $f, '<', $file)
527553 or die "$P: Can't open $file: $!\n";
528554 my $text = do { local($/) ; <$f> };
....@@ -533,10 +559,6 @@
533559 push(@keyword_tvi, $line);
534560 }
535561 }
536
- }
537
- if ($file_emails) {
538
- my @poss_addr = $text =~ m$[A-Za-zÀ-ÿ\"\' \,\.\+-]*\s*[\,]*\s*[\(\<\{]{0,1}[A-Za-z0-9_\.\+-]+\@[A-Za-z0-9\.-]+\.[A-Za-z0-9]+[\)\>\}]{0,1}$g;
539
- push(@file_emails, clean_file_emails(@poss_addr));
540562 }
541563 }
542564 } else {
....@@ -566,6 +588,8 @@
566588 my $filename2 = $2;
567589 push(@files, $filename1);
568590 push(@files, $filename2);
591
+ } elsif (m/^Fixes:\s+([0-9a-fA-F]{6,40})/) {
592
+ push(@fixes, $1) if ($email_fixes);
569593 } elsif (m/^\+\+\+\s+(\S+)/ or m/^---\s+(\S+)/) {
570594 my $filename = $1;
571595 $filename =~ s@^[^/]*/@@;
....@@ -596,6 +620,7 @@
596620 }
597621
598622 @file_emails = uniq(@file_emails);
623
+@fixes = uniq(@fixes);
599624
600625 my %email_hash_name;
601626 my %email_hash_address;
....@@ -610,7 +635,6 @@
610635 my %deduplicate_address_hash = ();
611636
612637 my @maintainers = get_maintainers();
613
-
614638 if (@maintainers) {
615639 @maintainers = merge_email(@maintainers);
616640 output(@maintainers);
....@@ -916,6 +940,8 @@
916940 print("\n");
917941 }
918942 }
943
+
944
+ maintainers_in_file($file);
919945 }
920946
921947 if ($keywords) {
....@@ -931,8 +957,10 @@
931957
932958 foreach my $file (@files) {
933959 if ($email &&
934
- ($email_git || ($email_git_fallback &&
935
- !$exact_pattern_match_hash{$file}))) {
960
+ ($email_git ||
961
+ ($email_git_fallback &&
962
+ $file !~ /MAINTAINERS$/ &&
963
+ !$exact_pattern_match_hash{$file}))) {
936964 vcs_file_signoffs($file);
937965 }
938966 if ($email && $email_git_blame) {
....@@ -961,6 +989,10 @@
961989 push_email_address($tmp_email, '');
962990 add_role($tmp_email, 'in file');
963991 }
992
+ }
993
+
994
+ foreach my $fix (@fixes) {
995
+ vcs_add_commit_signers($fix, "blamed_fixes");
964996 }
965997
966998 my @to = ();
....@@ -1023,11 +1055,13 @@
10231055 --r => include reviewer(s) if any
10241056 --n => include name 'Full Name <addr\@domain.tld>'
10251057 --l => include list(s) if any
1026
- --s => include subscriber only list(s) if any
1058
+ --moderated => include moderated lists(s) if any (default: true)
1059
+ --s => include subscriber only list(s) if any (default: false)
10271060 --remove-duplicates => minimize duplicate email names/addresses
10281061 --roles => show roles (status:subsystem, git-signer, list, etc...)
10291062 --rolestats => show roles and statistics (commits/total_commits, %)
10301063 --file-emails => add email addresses found in -f file (default: 0 (off))
1064
+ --fixes => for patches, add signatures of commits with 'Fixes: <commit>' (default: 1 (on))
10311065 --scm => print SCM tree(s) if any
10321066 --status => print status if any
10331067 --subsystem => print subsystem name if any
....@@ -1313,11 +1347,14 @@
13131347 } else {
13141348 if ($email_list) {
13151349 if (!$hash_list_to{lc($list_address)}) {
1316
- $hash_list_to{lc($list_address)} = 1;
13171350 if ($list_additional =~ m/moderated/) {
1318
- push(@list_to, [$list_address,
1319
- "moderated list${list_role}"]);
1351
+ if ($email_moderated_list) {
1352
+ $hash_list_to{lc($list_address)} = 1;
1353
+ push(@list_to, [$list_address,
1354
+ "moderated list${list_role}"]);
1355
+ }
13201356 } else {
1357
+ $hash_list_to{lc($list_address)} = 1;
13211358 push(@list_to, [$list_address,
13221359 "open list${list_role}"]);
13231360 }
....@@ -1325,35 +1362,11 @@
13251362 }
13261363 }
13271364 } elsif ($ptype eq "M") {
1328
- my ($name, $address) = parse_email($pvalue);
1329
- if ($name eq "") {
1330
- if ($i > 0) {
1331
- my $tv = $typevalue[$i - 1];
1332
- if ($tv =~ m/^([A-Z]):\s*(.*)/) {
1333
- if ($1 eq "P") {
1334
- $name = $2;
1335
- $pvalue = format_email($name, $address, $email_usename);
1336
- }
1337
- }
1338
- }
1339
- }
13401365 if ($email_maintainer) {
13411366 my $role = get_maintainer_role($i);
13421367 push_email_addresses($pvalue, $role);
13431368 }
13441369 } elsif ($ptype eq "R") {
1345
- my ($name, $address) = parse_email($pvalue);
1346
- if ($name eq "") {
1347
- if ($i > 0) {
1348
- my $tv = $typevalue[$i - 1];
1349
- if ($tv =~ m/^([A-Z]):\s*(.*)/) {
1350
- if ($1 eq "P") {
1351
- $name = $2;
1352
- $pvalue = format_email($name, $address, $email_usename);
1353
- }
1354
- }
1355
- }
1356
- }
13571370 if ($email_reviewer) {
13581371 my $subsystem = get_subsystem_name($i);
13591372 push_email_addresses($pvalue, "reviewer:$subsystem");
....@@ -1724,6 +1737,32 @@
17241737 return $vcs_used == 2;
17251738 }
17261739
1740
+sub vcs_add_commit_signers {
1741
+ return if (!vcs_exists());
1742
+
1743
+ my ($commit, $desc) = @_;
1744
+ my $commit_count = 0;
1745
+ my $commit_authors_ref;
1746
+ my $commit_signers_ref;
1747
+ my $stats_ref;
1748
+ my @commit_authors = ();
1749
+ my @commit_signers = ();
1750
+ my $cmd;
1751
+
1752
+ $cmd = $VCS_cmds{"find_commit_signers_cmd"};
1753
+ $cmd =~ s/(\$\w+)/$1/eeg; #substitute variables in $cmd
1754
+
1755
+ ($commit_count, $commit_signers_ref, $commit_authors_ref, $stats_ref) = vcs_find_signers($cmd, "");
1756
+ @commit_authors = @{$commit_authors_ref} if defined $commit_authors_ref;
1757
+ @commit_signers = @{$commit_signers_ref} if defined $commit_signers_ref;
1758
+
1759
+ foreach my $signer (@commit_signers) {
1760
+ $signer = deduplicate_email($signer);
1761
+ }
1762
+
1763
+ vcs_assign($desc, 1, @commit_signers);
1764
+}
1765
+
17271766 sub interactive_get_maintainers {
17281767 my ($list_ref) = @_;
17291768 my @list = @$list_ref;
....@@ -1817,7 +1856,7 @@
18171856 tg toggle git entries
18181857 tl toggle open list entries
18191858 ts toggle subscriber list entries
1820
-f emails in file [$file_emails]
1859
+f emails in file [$email_file_emails]
18211860 k keywords in file [$keywords]
18221861 r remove duplicates [$email_remove_duplicates]
18231862 p# pattern match depth [$pattern_depth]
....@@ -1942,7 +1981,7 @@
19421981 bool_invert(\$email_git_all_signature_types);
19431982 $rerun = 1;
19441983 } elsif ($sel eq "f") {
1945
- bool_invert(\$file_emails);
1984
+ bool_invert(\$email_file_emails);
19461985 $rerun = 1;
19471986 } elsif ($sel eq "r") {
19481987 bool_invert(\$email_remove_duplicates);