^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) #!/usr/bin/env perl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) # SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) # (c) 2007, Joe Perches <joe@perches.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) # created from checkpatch.pl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) # Print selected MAINTAINERS information for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) # the files modified in a patch or for a file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) # usage: perl scripts/get_maintainer.pl [OPTIONS] <patch>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) # perl scripts/get_maintainer.pl [OPTIONS] -f <file>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) use warnings;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) use strict;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) my $P = $0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) my $V = '0.26';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) use Getopt::Long qw(:config no_auto_abbrev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) use Cwd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) use File::Find;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) use File::Spec::Functions;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) my $cur_path = fastgetcwd() . '/';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) my $lk_path = "./";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) my $email = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) my $email_usename = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) my $email_maintainer = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) my $email_reviewer = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) my $email_fixes = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) my $email_list = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) my $email_moderated_list = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) my $email_subscriber_list = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) my $email_git_penguin_chiefs = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) my $email_git = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) my $email_git_all_signature_types = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) my $email_git_blame = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) my $email_git_blame_signatures = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) my $email_git_fallback = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) my $email_git_min_signatures = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) my $email_git_max_maintainers = 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) my $email_git_min_percent = 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) my $email_git_since = "1-year-ago";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) my $email_hg_since = "-365";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) my $interactive = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) my $email_remove_duplicates = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) my $email_use_mailmap = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) my $output_multiline = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) my $output_separator = ", ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) my $output_roles = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) my $output_rolestats = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) my $output_section_maxlen = 50;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) my $scm = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) my $tree = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) my $web = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) my $subsystem = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) my $status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) my $letters = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) my $keywords = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) my $sections = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) my $email_file_emails = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) my $from_filename = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) my $pattern_depth = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) my $self_test = undef;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) my $version = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) my $help = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) my $find_maintainer_files = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) my $maintainer_path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) my $vcs_used = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) my $exit = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) my @files = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) my @fixes = (); # If a patch description includes Fixes: lines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) my @range = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) my @keyword_tvi = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) my @file_emails = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) my %commit_author_hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) my %commit_signer_hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) my @penguin_chief = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) push(@penguin_chief, "Linus Torvalds:torvalds\@linux-foundation.org");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #Andrew wants in on most everything - 2009/01/14
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) #push(@penguin_chief, "Andrew Morton:akpm\@linux-foundation.org");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) my @penguin_chief_names = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) foreach my $chief (@penguin_chief) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) if ($chief =~ m/^(.*):(.*)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) my $chief_name = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) my $chief_addr = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) push(@penguin_chief_names, $chief_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) my $penguin_chiefs = "\(" . join("|", @penguin_chief_names) . "\)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) # Signature types of people who are either
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) # a) responsible for the code in question, or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) # b) familiar enough with it to give relevant feedback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) my @signature_tags = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) push(@signature_tags, "Signed-off-by:");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) push(@signature_tags, "Reviewed-by:");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) push(@signature_tags, "Acked-by:");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) my $signature_pattern = "\(" . join("|", @signature_tags) . "\)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) # rfc822 email address - preloaded methods go here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) my $rfc822_lwsp = "(?:(?:\\r\\n)?[ \\t])";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) my $rfc822_char = '[\\000-\\377]';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) # VCS command support: class-like functions and strings
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) my %VCS_cmds;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) my %VCS_cmds_git = (
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) "execute_cmd" => \&git_execute_cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) "available" => '(which("git") ne "") && (-e ".git")',
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) "find_signers_cmd" =>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) "git log --no-color --follow --since=\$email_git_since " .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) '--numstat --no-merges ' .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) '--format="GitCommit: %H%n' .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 'GitAuthor: %an <%ae>%n' .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 'GitDate: %aD%n' .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 'GitSubject: %s%n' .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) '%b%n"' .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) " -- \$file",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) "find_commit_signers_cmd" =>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) "git log --no-color " .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) '--numstat ' .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) '--format="GitCommit: %H%n' .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 'GitAuthor: %an <%ae>%n' .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 'GitDate: %aD%n' .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 'GitSubject: %s%n' .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) '%b%n"' .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) " -1 \$commit",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) "find_commit_author_cmd" =>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) "git log --no-color " .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) '--numstat ' .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) '--format="GitCommit: %H%n' .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 'GitAuthor: %an <%ae>%n' .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 'GitDate: %aD%n' .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 'GitSubject: %s%n"' .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) " -1 \$commit",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) "blame_range_cmd" => "git blame -l -L \$diff_start,+\$diff_length \$file",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) "blame_file_cmd" => "git blame -l \$file",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) "commit_pattern" => "^GitCommit: ([0-9a-f]{40,40})",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) "blame_commit_pattern" => "^([0-9a-f]+) ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) "author_pattern" => "^GitAuthor: (.*)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) "subject_pattern" => "^GitSubject: (.*)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) "stat_pattern" => "^(\\d+)\\t(\\d+)\\t\$file\$",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) "file_exists_cmd" => "git ls-files \$file",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) "list_files_cmd" => "git ls-files \$file",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) my %VCS_cmds_hg = (
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) "execute_cmd" => \&hg_execute_cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) "available" => '(which("hg") ne "") && (-d ".hg")',
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) "find_signers_cmd" =>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) "hg log --date=\$email_hg_since " .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) "--template='HgCommit: {node}\\n" .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) "HgAuthor: {author}\\n" .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) "HgSubject: {desc}\\n'" .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) " -- \$file",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) "find_commit_signers_cmd" =>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) "hg log " .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) "--template='HgSubject: {desc}\\n'" .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) " -r \$commit",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) "find_commit_author_cmd" =>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) "hg log " .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) "--template='HgCommit: {node}\\n" .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) "HgAuthor: {author}\\n" .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) "HgSubject: {desc|firstline}\\n'" .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) " -r \$commit",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) "blame_range_cmd" => "", # not supported
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) "blame_file_cmd" => "hg blame -n \$file",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) "commit_pattern" => "^HgCommit: ([0-9a-f]{40,40})",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) "blame_commit_pattern" => "^([ 0-9a-f]+):",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) "author_pattern" => "^HgAuthor: (.*)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) "subject_pattern" => "^HgSubject: (.*)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) "stat_pattern" => "^(\\d+)\t(\\d+)\t\$file\$",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) "file_exists_cmd" => "hg files \$file",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) "list_files_cmd" => "hg manifest -R \$file",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) my $conf = which_conf(".get_maintainer.conf");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) if (-f $conf) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) my @conf_args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) open(my $conffile, '<', "$conf")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) or warn "$P: Can't find a readable .get_maintainer.conf file $!\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) while (<$conffile>) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) my $line = $_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) $line =~ s/\s*\n?$//g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) $line =~ s/^\s*//g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) $line =~ s/\s+/ /g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) next if ($line =~ m/^\s*#/);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) next if ($line =~ m/^\s*$/);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) my @words = split(" ", $line);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) foreach my $word (@words) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) last if ($word =~ m/^#/);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) push (@conf_args, $word);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) close($conffile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) unshift(@ARGV, @conf_args) if @conf_args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) my @ignore_emails = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) my $ignore_file = which_conf(".get_maintainer.ignore");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) if (-f $ignore_file) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) open(my $ignore, '<', "$ignore_file")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) or warn "$P: Can't find a readable .get_maintainer.ignore file $!\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) while (<$ignore>) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) my $line = $_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) $line =~ s/\s*\n?$//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) $line =~ s/^\s*//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) $line =~ s/\s+$//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) $line =~ s/#.*$//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) next if ($line =~ m/^\s*$/);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) if (rfc822_valid($line)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) push(@ignore_emails, $line);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) close($ignore);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) if ($#ARGV > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) foreach (@ARGV) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) if ($_ =~ /^-{1,2}self-test(?:=|$)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) die "$P: using --self-test does not allow any other option or argument\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) if (!GetOptions(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 'email!' => \$email,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 'git!' => \$email_git,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 'git-all-signature-types!' => \$email_git_all_signature_types,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 'git-blame!' => \$email_git_blame,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 'git-blame-signatures!' => \$email_git_blame_signatures,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 'git-fallback!' => \$email_git_fallback,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 'git-chief-penguins!' => \$email_git_penguin_chiefs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 'git-min-signatures=i' => \$email_git_min_signatures,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 'git-max-maintainers=i' => \$email_git_max_maintainers,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 'git-min-percent=i' => \$email_git_min_percent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 'git-since=s' => \$email_git_since,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 'hg-since=s' => \$email_hg_since,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 'i|interactive!' => \$interactive,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 'remove-duplicates!' => \$email_remove_duplicates,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 'mailmap!' => \$email_use_mailmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 'm!' => \$email_maintainer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 'r!' => \$email_reviewer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 'n!' => \$email_usename,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 'l!' => \$email_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 'fixes!' => \$email_fixes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 'moderated!' => \$email_moderated_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 's!' => \$email_subscriber_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 'multiline!' => \$output_multiline,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 'roles!' => \$output_roles,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 'rolestats!' => \$output_rolestats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 'separator=s' => \$output_separator,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 'subsystem!' => \$subsystem,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 'status!' => \$status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 'scm!' => \$scm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 'tree!' => \$tree,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 'web!' => \$web,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 'letters=s' => \$letters,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 'pattern-depth=i' => \$pattern_depth,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 'k|keywords!' => \$keywords,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 'sections!' => \$sections,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 'fe|file-emails!' => \$email_file_emails,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 'f|file' => \$from_filename,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 'find-maintainer-files' => \$find_maintainer_files,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 'mpath|maintainer-path=s' => \$maintainer_path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 'self-test:s' => \$self_test,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 'v|version' => \$version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 'h|help|usage' => \$help,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) )) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) die "$P: invalid argument - use --help if necessary\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) if ($help != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) usage();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) exit 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) if ($version != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) print("${P} ${V}\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) exit 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) if (defined $self_test) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) read_all_maintainer_files();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) self_test();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) exit 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) if (-t STDIN && !@ARGV) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) # We're talking to a terminal, but have no command line arguments.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) die "$P: missing patchfile or -f file - use --help if necessary\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) $output_multiline = 0 if ($output_separator ne ", ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) $output_rolestats = 1 if ($interactive);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) $output_roles = 1 if ($output_rolestats);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) if ($sections || $letters ne "") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) $sections = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) $email = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) $email_list = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) $scm = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) $status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) $subsystem = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) $web = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) $keywords = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) $interactive = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) my $selections = $email + $scm + $status + $subsystem + $web;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) if ($selections == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) die "$P: Missing required option: email, scm, status, subsystem or web\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) if ($email &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) ($email_maintainer + $email_reviewer +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) $email_list + $email_subscriber_list +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) $email_git + $email_git_penguin_chiefs + $email_git_blame) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) die "$P: Please select at least 1 email option\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) if ($tree && !top_of_kernel_tree($lk_path)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) die "$P: The current directory does not appear to be "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) . "a linux kernel source tree.\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) ## Read MAINTAINERS for type/value pairs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) my @typevalue = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) my %keyword_hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) my @mfiles = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) my @self_test_info = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) sub read_maintainer_file {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) my ($file) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) open (my $maint, '<', "$file")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) or die "$P: Can't open MAINTAINERS file '$file': $!\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) my $i = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) while (<$maint>) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) my $line = $_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) chomp $line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) if ($line =~ m/^([A-Z]):\s*(.*)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) my $type = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) my $value = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) ##Filename pattern matching
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) if ($type eq "F" || $type eq "X") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) $value =~ s@\.@\\\.@g; ##Convert . to \.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) $value =~ s/\*/\.\*/g; ##Convert * to .*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) $value =~ s/\?/\./g; ##Convert ? to .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) ##if pattern is a directory and it lacks a trailing slash, add one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) if ((-d $value)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) $value =~ s@([^/])$@$1/@;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) } elsif ($type eq "K") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) $keyword_hash{@typevalue} = $value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) push(@typevalue, "$type:$value");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) } elsif (!(/^\s*$/ || /^\s*\#/)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) push(@typevalue, $line);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) if (defined $self_test) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) push(@self_test_info, {file=>$file, linenr=>$i, line=>$line});
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) $i++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) close($maint);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) sub find_is_maintainer_file {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) my ($file) = $_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) return if ($file !~ m@/MAINTAINERS$@);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) $file = $File::Find::name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) return if (! -f $file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) push(@mfiles, $file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) sub find_ignore_git {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) return grep { $_ !~ /^\.git$/; } @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) read_all_maintainer_files();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) sub read_all_maintainer_files {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) my $path = "${lk_path}MAINTAINERS";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) if (defined $maintainer_path) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) $path = $maintainer_path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) # Perl Cookbook tilde expansion if necessary
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) $path =~ s@^~([^/]*)@ $1 ? (getpwnam($1))[7] : ( $ENV{HOME} || $ENV{LOGDIR} || (getpwuid($<))[7])@ex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) if (-d $path) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) $path .= '/' if ($path !~ m@/$@);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) if ($find_maintainer_files) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) find( { wanted => \&find_is_maintainer_file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) preprocess => \&find_ignore_git,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) no_chdir => 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) }, "$path");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) opendir(DIR, "$path") or die $!;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) my @files = readdir(DIR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) closedir(DIR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) foreach my $file (@files) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) push(@mfiles, "$path$file") if ($file !~ /^\./);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) } elsif (-f "$path") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) push(@mfiles, "$path");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) die "$P: MAINTAINER file not found '$path'\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) die "$P: No MAINTAINER files found in '$path'\n" if (scalar(@mfiles) == 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) foreach my $file (@mfiles) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) read_maintainer_file("$file");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) sub maintainers_in_file {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) my ($file) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) return if ($file =~ m@\bMAINTAINERS$@);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) if (-f $file && ($email_file_emails || $file =~ /\.yaml$/)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) open(my $f, '<', $file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) or die "$P: Can't open $file: $!\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) my $text = do { local($/) ; <$f> };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) close($f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 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;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) push(@file_emails, clean_file_emails(@poss_addr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) # Read mail address map
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) my $mailmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) read_mailmap();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) sub read_mailmap {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) $mailmap = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) names => {},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) addresses => {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) return if (!$email_use_mailmap || !(-f "${lk_path}.mailmap"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) open(my $mailmap_file, '<', "${lk_path}.mailmap")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) or warn "$P: Can't open .mailmap: $!\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) while (<$mailmap_file>) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) s/#.*$//; #strip comments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) s/^\s+|\s+$//g; #trim
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) next if (/^\s*$/); #skip empty lines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) #entries have one of the following formats:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) # name1 <mail1>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) # <mail1> <mail2>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) # name1 <mail1> <mail2>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) # name1 <mail1> name2 <mail2>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) # (see man git-shortlog)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) if (/^([^<]+)<([^>]+)>$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) my $real_name = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) my $address = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) $real_name =~ s/\s+$//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) ($real_name, $address) = parse_email("$real_name <$address>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) $mailmap->{names}->{$address} = $real_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) } elsif (/^<([^>]+)>\s*<([^>]+)>$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) my $real_address = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) my $wrong_address = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) $mailmap->{addresses}->{$wrong_address} = $real_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) } elsif (/^(.+)<([^>]+)>\s*<([^>]+)>$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) my $real_name = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) my $real_address = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) my $wrong_address = $3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) $real_name =~ s/\s+$//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) ($real_name, $real_address) =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) parse_email("$real_name <$real_address>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) $mailmap->{names}->{$wrong_address} = $real_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) $mailmap->{addresses}->{$wrong_address} = $real_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) } elsif (/^(.+)<([^>]+)>\s*(.+)\s*<([^>]+)>$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) my $real_name = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) my $real_address = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) my $wrong_name = $3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) my $wrong_address = $4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) $real_name =~ s/\s+$//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) ($real_name, $real_address) =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) parse_email("$real_name <$real_address>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) $wrong_name =~ s/\s+$//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) ($wrong_name, $wrong_address) =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) parse_email("$wrong_name <$wrong_address>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) my $wrong_email = format_email($wrong_name, $wrong_address, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) $mailmap->{names}->{$wrong_email} = $real_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) $mailmap->{addresses}->{$wrong_email} = $real_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) close($mailmap_file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) ## use the filenames on the command line or find the filenames in the patchfiles
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) if (!@ARGV) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) push(@ARGV, "&STDIN");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) foreach my $file (@ARGV) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) if ($file ne "&STDIN") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) $file = canonpath($file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) ##if $file is a directory and it lacks a trailing slash, add one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) if ((-d $file)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) $file =~ s@([^/])$@$1/@;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) } elsif (!(-f $file)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) die "$P: file '${file}' not found\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) if ($from_filename && (vcs_exists() && !vcs_file_exists($file))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) warn "$P: file '$file' not found in version control $!\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) if ($from_filename || ($file ne "&STDIN" && vcs_file_exists($file))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) $file =~ s/^\Q${cur_path}\E//; #strip any absolute path
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) $file =~ s/^\Q${lk_path}\E//; #or the path to the lk tree
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) push(@files, $file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) if ($file ne "MAINTAINERS" && -f $file && $keywords) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) open(my $f, '<', $file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) or die "$P: Can't open $file: $!\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) my $text = do { local($/) ; <$f> };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) close($f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) if ($keywords) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) foreach my $line (keys %keyword_hash) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) if ($text =~ m/$keyword_hash{$line}/x) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) push(@keyword_tvi, $line);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) my $file_cnt = @files;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) my $lastfile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) open(my $patch, "< $file")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) or die "$P: Can't open $file: $!\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) # We can check arbitrary information before the patch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) # like the commit message, mail headers, etc...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) # This allows us to match arbitrary keywords against any part
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) # of a git format-patch generated file (subject tags, etc...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) my $patch_prefix = ""; #Parsing the intro
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) while (<$patch>) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) my $patch_line = $_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) if (m/^ mode change [0-7]+ => [0-7]+ (\S+)\s*$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) my $filename = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) push(@files, $filename);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) } elsif (m/^rename (?:from|to) (\S+)\s*$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) my $filename = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) push(@files, $filename);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) } elsif (m/^diff --git a\/(\S+) b\/(\S+)\s*$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) my $filename1 = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) my $filename2 = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) push(@files, $filename1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) push(@files, $filename2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) } elsif (m/^Fixes:\s+([0-9a-fA-F]{6,40})/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) push(@fixes, $1) if ($email_fixes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) } elsif (m/^\+\+\+\s+(\S+)/ or m/^---\s+(\S+)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) my $filename = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) $filename =~ s@^[^/]*/@@;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) $filename =~ s@\n@@;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) $lastfile = $filename;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) push(@files, $filename);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) $patch_prefix = "^[+-].*"; #Now parsing the actual patch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) } elsif (m/^\@\@ -(\d+),(\d+)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) if ($email_git_blame) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) push(@range, "$lastfile:$1:$2");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) } elsif ($keywords) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) foreach my $line (keys %keyword_hash) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) if ($patch_line =~ m/${patch_prefix}$keyword_hash{$line}/x) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) push(@keyword_tvi, $line);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) close($patch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) if ($file_cnt == @files) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) warn "$P: file '${file}' doesn't appear to be a patch. "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) . "Add -f to options?\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) @files = sort_and_uniq(@files);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) @file_emails = uniq(@file_emails);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) @fixes = uniq(@fixes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) my %email_hash_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) my %email_hash_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) my @email_to = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) my %hash_list_to;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) my @list_to = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) my @scm = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) my @web = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) my @subsystem = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) my @status = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) my %deduplicate_name_hash = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) my %deduplicate_address_hash = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) my @maintainers = get_maintainers();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) if (@maintainers) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) @maintainers = merge_email(@maintainers);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) output(@maintainers);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) if ($scm) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) @scm = uniq(@scm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) output(@scm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) if ($status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) @status = uniq(@status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) output(@status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) if ($subsystem) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) @subsystem = uniq(@subsystem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) output(@subsystem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) if ($web) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) @web = uniq(@web);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) output(@web);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) exit($exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) sub self_test {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) my @lsfiles = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) my @good_links = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) my @bad_links = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) my @section_headers = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) my $index = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) @lsfiles = vcs_list_files($lk_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) for my $x (@self_test_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) $index++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) ## Section header duplication and missing section content
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) if (($self_test eq "" || $self_test =~ /\bsections\b/) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) $x->{line} =~ /^\S[^:]/ &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) defined $self_test_info[$index] &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) $self_test_info[$index]->{line} =~ /^([A-Z]):\s*\S/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) my $has_S = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) my $has_F = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) my $has_ML = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) my $status = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) if (grep(m@^\Q$x->{line}\E@, @section_headers)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) print("$x->{file}:$x->{linenr}: warning: duplicate section header\t$x->{line}\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) push(@section_headers, $x->{line});
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) my $nextline = $index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) while (defined $self_test_info[$nextline] &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) $self_test_info[$nextline]->{line} =~ /^([A-Z]):\s*(\S.*)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) my $type = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) my $value = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) if ($type eq "S") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) $has_S = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) $status = $value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) } elsif ($type eq "F" || $type eq "N") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) $has_F = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) } elsif ($type eq "M" || $type eq "R" || $type eq "L") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) $has_ML = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) $nextline++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) if (!$has_ML && $status !~ /orphan|obsolete/i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) print("$x->{file}:$x->{linenr}: warning: section without email address\t$x->{line}\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) if (!$has_S) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) print("$x->{file}:$x->{linenr}: warning: section without status \t$x->{line}\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) if (!$has_F) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) print("$x->{file}:$x->{linenr}: warning: section without file pattern\t$x->{line}\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) next if ($x->{line} !~ /^([A-Z]):\s*(.*)/);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) my $type = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) my $value = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) ## Filename pattern matching
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) if (($type eq "F" || $type eq "X") &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) ($self_test eq "" || $self_test =~ /\bpatterns\b/)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) $value =~ s@\.@\\\.@g; ##Convert . to \.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) $value =~ s/\*/\.\*/g; ##Convert * to .*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) $value =~ s/\?/\./g; ##Convert ? to .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) ##if pattern is a directory and it lacks a trailing slash, add one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) if ((-d $value)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) $value =~ s@([^/])$@$1/@;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) if (!grep(m@^$value@, @lsfiles)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) print("$x->{file}:$x->{linenr}: warning: no file matches\t$x->{line}\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) ## Link reachability
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) } elsif (($type eq "W" || $type eq "Q" || $type eq "B") &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) $value =~ /^https?:/ &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) ($self_test eq "" || $self_test =~ /\blinks\b/)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) next if (grep(m@^\Q$value\E$@, @good_links));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) my $isbad = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) if (grep(m@^\Q$value\E$@, @bad_links)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) $isbad = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) my $output = `wget --spider -q --no-check-certificate --timeout 10 --tries 1 $value`;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) if ($? == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) push(@good_links, $value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) push(@bad_links, $value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) $isbad = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) if ($isbad) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) print("$x->{file}:$x->{linenr}: warning: possible bad link\t$x->{line}\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) ## SCM reachability
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) } elsif ($type eq "T" &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) ($self_test eq "" || $self_test =~ /\bscm\b/)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) next if (grep(m@^\Q$value\E$@, @good_links));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) my $isbad = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) if (grep(m@^\Q$value\E$@, @bad_links)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) $isbad = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) } elsif ($value !~ /^(?:git|quilt|hg)\s+\S/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) print("$x->{file}:$x->{linenr}: warning: malformed entry\t$x->{line}\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) } elsif ($value =~ /^git\s+(\S+)(\s+([^\(]+\S+))?/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) my $url = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) my $branch = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) $branch = $3 if $3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) my $output = `git ls-remote --exit-code -h "$url" $branch > /dev/null 2>&1`;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) if ($? == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) push(@good_links, $value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) push(@bad_links, $value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) $isbad = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) } elsif ($value =~ /^(?:quilt|hg)\s+(https?:\S+)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) my $url = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) my $output = `wget --spider -q --no-check-certificate --timeout 10 --tries 1 $url`;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) if ($? == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) push(@good_links, $value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) push(@bad_links, $value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) $isbad = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) if ($isbad) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) print("$x->{file}:$x->{linenr}: warning: possible bad link\t$x->{line}\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) sub ignore_email_address {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) my ($address) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) foreach my $ignore (@ignore_emails) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) return 1 if ($ignore eq $address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) sub range_is_maintained {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) my ($start, $end) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) for (my $i = $start; $i < $end; $i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) my $line = $typevalue[$i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) if ($line =~ m/^([A-Z]):\s*(.*)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) my $type = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) my $value = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) if ($type eq 'S') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) if ($value =~ /(maintain|support)/i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) sub range_has_maintainer {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) my ($start, $end) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) for (my $i = $start; $i < $end; $i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) my $line = $typevalue[$i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) if ($line =~ m/^([A-Z]):\s*(.*)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) my $type = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) my $value = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) if ($type eq 'M') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) sub get_maintainers {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) %email_hash_name = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) %email_hash_address = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) %commit_author_hash = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) %commit_signer_hash = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) @email_to = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) %hash_list_to = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) @list_to = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) @scm = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) @web = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) @subsystem = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) @status = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) %deduplicate_name_hash = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) %deduplicate_address_hash = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) if ($email_git_all_signature_types) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) $signature_pattern = "(.+?)[Bb][Yy]:";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) $signature_pattern = "\(" . join("|", @signature_tags) . "\)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) # Find responsible parties
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) my %exact_pattern_match_hash = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) foreach my $file (@files) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) my %hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) my $tvi = find_first_section();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) while ($tvi < @typevalue) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) my $start = find_starting_index($tvi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) my $end = find_ending_index($tvi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) my $exclude = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) my $i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) #Do not match excluded file patterns
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) for ($i = $start; $i < $end; $i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) my $line = $typevalue[$i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) if ($line =~ m/^([A-Z]):\s*(.*)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) my $type = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) my $value = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) if ($type eq 'X') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) if (file_match_pattern($file, $value)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) $exclude = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) if (!$exclude) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) for ($i = $start; $i < $end; $i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) my $line = $typevalue[$i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) if ($line =~ m/^([A-Z]):\s*(.*)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) my $type = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) my $value = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) if ($type eq 'F') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) if (file_match_pattern($file, $value)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) my $value_pd = ($value =~ tr@/@@);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) my $file_pd = ($file =~ tr@/@@);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) $value_pd++ if (substr($value,-1,1) ne "/");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) $value_pd = -1 if ($value =~ /^\.\*/);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) if ($value_pd >= $file_pd &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) range_is_maintained($start, $end) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) range_has_maintainer($start, $end)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) $exact_pattern_match_hash{$file} = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) if ($pattern_depth == 0 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) (($file_pd - $value_pd) < $pattern_depth)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) $hash{$tvi} = $value_pd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) } elsif ($type eq 'N') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) if ($file =~ m/$value/x) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) $hash{$tvi} = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) $tvi = $end + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) foreach my $line (sort {$hash{$b} <=> $hash{$a}} keys %hash) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) add_categories($line);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) if ($sections) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) my $i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) my $start = find_starting_index($line);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) my $end = find_ending_index($line);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) for ($i = $start; $i < $end; $i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) my $line = $typevalue[$i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) if ($line =~ /^[FX]:/) { ##Restore file patterns
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) $line =~ s/([^\\])\.([^\*])/$1\?$2/g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) $line =~ s/([^\\])\.$/$1\?/g; ##Convert . back to ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) $line =~ s/\\\./\./g; ##Convert \. to .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) $line =~ s/\.\*/\*/g; ##Convert .* to *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) my $count = $line =~ s/^([A-Z]):/$1:\t/g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) if ($letters eq "" || (!$count || $letters =~ /$1/i)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) print("$line\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) print("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) maintainers_in_file($file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) if ($keywords) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) @keyword_tvi = sort_and_uniq(@keyword_tvi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) foreach my $line (@keyword_tvi) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950) add_categories($line);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) foreach my $email (@email_to, @list_to) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) $email->[0] = deduplicate_email($email->[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) foreach my $file (@files) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) if ($email &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) ($email_git ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) ($email_git_fallback &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) $file !~ /MAINTAINERS$/ &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) !$exact_pattern_match_hash{$file}))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) vcs_file_signoffs($file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) if ($email && $email_git_blame) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) vcs_file_blame($file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) if ($email) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) foreach my $chief (@penguin_chief) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) if ($chief =~ m/^(.*):(.*)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) my $email_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) $email_address = format_email($1, $2, $email_usename);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) if ($email_git_penguin_chiefs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) push(@email_to, [$email_address, 'chief penguin']);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) @email_to = grep($_->[0] !~ /${email_address}/, @email_to);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) foreach my $email (@file_emails) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) my ($name, $address) = parse_email($email);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) my $tmp_email = format_email($name, $address, $email_usename);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) push_email_address($tmp_email, '');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) add_role($tmp_email, 'in file');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) foreach my $fix (@fixes) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995) vcs_add_commit_signers($fix, "blamed_fixes");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) my @to = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) if ($email || $email_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) if ($email) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) @to = (@to, @email_to);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) if ($email_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) @to = (@to, @list_to);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) if ($interactive) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) @to = interactive_get_maintainers(\@to);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) return @to;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) sub file_match_pattern {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) my ($file, $pattern) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) if (substr($pattern, -1) eq "/") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) if ($file =~ m@^$pattern@) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) if ($file =~ m@^$pattern@) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) my $s1 = ($file =~ tr@/@@);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) my $s2 = ($pattern =~ tr@/@@);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) if ($s1 == $s2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) sub usage {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) print <<EOT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) usage: $P [options] patchfile
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) $P [options] -f file|directory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) version: $V
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) MAINTAINER field selection options:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) --email => print email address(es) if any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) --git => include recent git \*-by: signers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) --git-all-signature-types => include signers regardless of signature type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) or use only ${signature_pattern} signers (default: $email_git_all_signature_types)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) --git-fallback => use git when no exact MAINTAINERS pattern (default: $email_git_fallback)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) --git-chief-penguins => include ${penguin_chiefs}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) --git-min-signatures => number of signatures required (default: $email_git_min_signatures)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) --git-max-maintainers => maximum maintainers to add (default: $email_git_max_maintainers)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) --git-min-percent => minimum percentage of commits required (default: $email_git_min_percent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) --git-blame => use git blame to find modified commits for patch or file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) --git-blame-signatures => when used with --git-blame, also include all commit signers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) --git-since => git history to use (default: $email_git_since)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) --hg-since => hg history to use (default: $email_hg_since)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) --interactive => display a menu (mostly useful if used with the --git option)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) --m => include maintainer(s) if any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) --r => include reviewer(s) if any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) --n => include name 'Full Name <addr\@domain.tld>'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) --l => include list(s) if any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) --moderated => include moderated lists(s) if any (default: true)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) --s => include subscriber only list(s) if any (default: false)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) --remove-duplicates => minimize duplicate email names/addresses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) --roles => show roles (status:subsystem, git-signer, list, etc...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) --rolestats => show roles and statistics (commits/total_commits, %)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) --file-emails => add email addresses found in -f file (default: 0 (off))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) --fixes => for patches, add signatures of commits with 'Fixes: <commit>' (default: 1 (on))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) --scm => print SCM tree(s) if any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) --status => print status if any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) --subsystem => print subsystem name if any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) --web => print website(s) if any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) Output type options:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) --separator [, ] => separator for multiple entries on 1 line
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) using --separator also sets --nomultiline if --separator is not [, ]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) --multiline => print 1 entry per line
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) Other options:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) --pattern-depth => Number of pattern directory traversals (default: 0 (all))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) --keywords => scan patch for keywords (default: $keywords)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) --sections => print all of the subsystem sections with pattern matches
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) --letters => print all matching 'letter' types from all matching sections
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) --mailmap => use .mailmap file (default: $email_use_mailmap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) --no-tree => run without a kernel tree
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) --self-test => show potential issues with MAINTAINERS file content
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) --version => show version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) --help => show this help information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) Default options:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) [--email --tree --nogit --git-fallback --m --r --n --l --multiline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) --pattern-depth=0 --remove-duplicates --rolestats]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) Notes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) Using "-f directory" may give unexpected results:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) Used with "--git", git signators for _all_ files in and below
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) directory are examined as git recurses directories.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) Any specified X: (exclude) pattern matches are _not_ ignored.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) Used with "--nogit", directory is used as a pattern match,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) no individual file within the directory or subdirectory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) is matched.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) Used with "--git-blame", does not iterate all files in directory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) Using "--git-blame" is slow and may add old committers and authors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) that are no longer active maintainers to the output.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) Using "--roles" or "--rolestats" with git send-email --cc-cmd or any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) other automated tools that expect only ["name"] <email address>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) may not work because of additional output after <email address>.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) Using "--rolestats" and "--git-blame" shows the #/total=% commits,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) not the percentage of the entire file authored. # of commits is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) not a good measure of amount of code authored. 1 major commit may
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) contain a thousand lines, 5 trivial commits may modify a single line.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) If git is not installed, but mercurial (hg) is installed and an .hg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) repository exists, the following options apply to mercurial:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) --git,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) --git-min-signatures, --git-max-maintainers, --git-min-percent, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) --git-blame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) Use --hg-since not --git-since to control date selection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) File ".get_maintainer.conf", if it exists in the linux kernel source root
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) directory, can change whatever get_maintainer defaults are desired.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) Entries in this file can be any command line argument.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) This file is prepended to any additional command line arguments.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) Multiple lines and # comments are allowed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) Most options have both positive and negative forms.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) The negative forms for --<foo> are --no<foo> and --no-<foo>.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) EOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) sub top_of_kernel_tree {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) my ($lk_path) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) if ($lk_path ne "" && substr($lk_path,length($lk_path)-1,1) ne "/") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) $lk_path .= "/";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) if ( (-f "${lk_path}COPYING")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) && (-f "${lk_path}CREDITS")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) && (-f "${lk_path}Kbuild")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) && (-e "${lk_path}MAINTAINERS")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) && (-f "${lk_path}Makefile")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) && (-f "${lk_path}README")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) && (-d "${lk_path}Documentation")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) && (-d "${lk_path}arch")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) && (-d "${lk_path}include")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) && (-d "${lk_path}drivers")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) && (-d "${lk_path}fs")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) && (-d "${lk_path}init")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) && (-d "${lk_path}ipc")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) && (-d "${lk_path}kernel")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) && (-d "${lk_path}lib")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) && (-d "${lk_path}scripts")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) sub parse_email {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) my ($formatted_email) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) my $name = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) my $address = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) if ($formatted_email =~ /^([^<]+)<(.+\@.*)>.*$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) $name = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) $address = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) } elsif ($formatted_email =~ /^\s*<(.+\@\S*)>.*$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) $address = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) } elsif ($formatted_email =~ /^(.+\@\S*).*$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) $address = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) $name =~ s/^\s+|\s+$//g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) $name =~ s/^\"|\"$//g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) $address =~ s/^\s+|\s+$//g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) if ($name =~ /[^\w \-]/i) { ##has "must quote" chars
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) $name =~ s/(?<!\\)"/\\"/g; ##escape quotes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) $name = "\"$name\"";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) return ($name, $address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) sub format_email {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) my ($name, $address, $usename) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) my $formatted_email;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) $name =~ s/^\s+|\s+$//g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) $name =~ s/^\"|\"$//g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) $address =~ s/^\s+|\s+$//g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) if ($name =~ /[^\w \-]/i) { ##has "must quote" chars
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) $name =~ s/(?<!\\)"/\\"/g; ##escape quotes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) $name = "\"$name\"";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) if ($usename) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) if ("$name" eq "") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) $formatted_email = "$address";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) $formatted_email = "$name <$address>";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) $formatted_email = $address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) return $formatted_email;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) sub find_first_section {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) my $index = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) while ($index < @typevalue) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) my $tv = $typevalue[$index];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) if (($tv =~ m/^([A-Z]):\s*(.*)/)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) $index++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) return $index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) sub find_starting_index {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) my ($index) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) while ($index > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) my $tv = $typevalue[$index];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) if (!($tv =~ m/^([A-Z]):\s*(.*)/)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) $index--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) return $index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) sub find_ending_index {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) my ($index) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) while ($index < @typevalue) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) my $tv = $typevalue[$index];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) if (!($tv =~ m/^([A-Z]):\s*(.*)/)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) $index++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) return $index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) sub get_subsystem_name {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) my ($index) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) my $start = find_starting_index($index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) my $subsystem = $typevalue[$start];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) if ($output_section_maxlen && length($subsystem) > $output_section_maxlen) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) $subsystem = substr($subsystem, 0, $output_section_maxlen - 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) $subsystem =~ s/\s*$//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) $subsystem = $subsystem . "...";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) return $subsystem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) sub get_maintainer_role {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) my ($index) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) my $i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) my $start = find_starting_index($index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) my $end = find_ending_index($index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) my $role = "unknown";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) my $subsystem = get_subsystem_name($index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) for ($i = $start + 1; $i < $end; $i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) my $tv = $typevalue[$i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) if ($tv =~ m/^([A-Z]):\s*(.*)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) my $ptype = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) my $pvalue = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) if ($ptype eq "S") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) $role = $pvalue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) $role = lc($role);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) if ($role eq "supported") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) $role = "supporter";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) } elsif ($role eq "maintained") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) $role = "maintainer";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) } elsif ($role eq "odd fixes") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) $role = "odd fixer";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) } elsif ($role eq "orphan") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) $role = "orphan minder";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) } elsif ($role eq "obsolete") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) $role = "obsolete minder";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) } elsif ($role eq "buried alive in reporters") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) $role = "chief penguin";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) return $role . ":" . $subsystem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) sub get_list_role {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) my ($index) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) my $subsystem = get_subsystem_name($index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) if ($subsystem eq "THE REST") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) $subsystem = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) return $subsystem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) sub add_categories {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) my ($index) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) my $i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) my $start = find_starting_index($index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) my $end = find_ending_index($index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) push(@subsystem, $typevalue[$start]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) for ($i = $start + 1; $i < $end; $i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) my $tv = $typevalue[$i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) if ($tv =~ m/^([A-Z]):\s*(.*)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) my $ptype = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) my $pvalue = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) if ($ptype eq "L") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) my $list_address = $pvalue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) my $list_additional = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) my $list_role = get_list_role($i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) if ($list_role ne "") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) $list_role = ":" . $list_role;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) if ($list_address =~ m/([^\s]+)\s+(.*)$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) $list_address = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) $list_additional = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) if ($list_additional =~ m/subscribers-only/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) if ($email_subscriber_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) if (!$hash_list_to{lc($list_address)}) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) $hash_list_to{lc($list_address)} = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) push(@list_to, [$list_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) "subscriber list${list_role}"]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) if ($email_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) if (!$hash_list_to{lc($list_address)}) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) if ($list_additional =~ m/moderated/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) if ($email_moderated_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) $hash_list_to{lc($list_address)} = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) push(@list_to, [$list_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) "moderated list${list_role}"]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) $hash_list_to{lc($list_address)} = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) push(@list_to, [$list_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) "open list${list_role}"]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) } elsif ($ptype eq "M") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) if ($email_maintainer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) my $role = get_maintainer_role($i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) push_email_addresses($pvalue, $role);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) } elsif ($ptype eq "R") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) if ($email_reviewer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) my $subsystem = get_subsystem_name($i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) push_email_addresses($pvalue, "reviewer:$subsystem");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) } elsif ($ptype eq "T") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) push(@scm, $pvalue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) } elsif ($ptype eq "W") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) push(@web, $pvalue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) } elsif ($ptype eq "S") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) push(@status, $pvalue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) sub email_inuse {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) my ($name, $address) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) return 1 if (($name eq "") && ($address eq ""));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) return 1 if (($name ne "") && exists($email_hash_name{lc($name)}));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) return 1 if (($address ne "") && exists($email_hash_address{lc($address)}));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) sub push_email_address {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) my ($line, $role) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) my ($name, $address) = parse_email($line);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) if ($address eq "") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) if (!$email_remove_duplicates) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) push(@email_to, [format_email($name, $address, $email_usename), $role]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) } elsif (!email_inuse($name, $address)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) push(@email_to, [format_email($name, $address, $email_usename), $role]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) $email_hash_name{lc($name)}++ if ($name ne "");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) $email_hash_address{lc($address)}++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) sub push_email_addresses {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) my ($address, $role) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) my @address_list = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) if (rfc822_valid($address)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) push_email_address($address, $role);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) } elsif (@address_list = rfc822_validlist($address)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) my $array_count = shift(@address_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) while (my $entry = shift(@address_list)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) push_email_address($entry, $role);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) if (!push_email_address($address, $role)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) warn("Invalid MAINTAINERS address: '" . $address . "'\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) sub add_role {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) my ($line, $role) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) my ($name, $address) = parse_email($line);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) my $email = format_email($name, $address, $email_usename);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) foreach my $entry (@email_to) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) if ($email_remove_duplicates) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) my ($entry_name, $entry_address) = parse_email($entry->[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) if (($name eq $entry_name || $address eq $entry_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) && ($role eq "" || !($entry->[1] =~ m/$role/))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) if ($entry->[1] eq "") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) $entry->[1] = "$role";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) $entry->[1] = "$entry->[1],$role";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) if ($email eq $entry->[0]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) && ($role eq "" || !($entry->[1] =~ m/$role/))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) if ($entry->[1] eq "") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) $entry->[1] = "$role";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) $entry->[1] = "$entry->[1],$role";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) sub which {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) my ($bin) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) foreach my $path (split(/:/, $ENV{PATH})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) if (-e "$path/$bin") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) return "$path/$bin";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) return "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) sub which_conf {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) my ($conf) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) foreach my $path (split(/:/, ".:$ENV{HOME}:.scripts")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) if (-e "$path/$conf") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) return "$path/$conf";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) return "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) sub mailmap_email {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) my ($line) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) my ($name, $address) = parse_email($line);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) my $email = format_email($name, $address, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) my $real_name = $name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) my $real_address = $address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) if (exists $mailmap->{names}->{$email} ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) exists $mailmap->{addresses}->{$email}) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) if (exists $mailmap->{names}->{$email}) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) $real_name = $mailmap->{names}->{$email};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) if (exists $mailmap->{addresses}->{$email}) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) $real_address = $mailmap->{addresses}->{$email};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) if (exists $mailmap->{names}->{$address}) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) $real_name = $mailmap->{names}->{$address};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) if (exists $mailmap->{addresses}->{$address}) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) $real_address = $mailmap->{addresses}->{$address};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) return format_email($real_name, $real_address, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) sub mailmap {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) my (@addresses) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) my @mapped_emails = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) foreach my $line (@addresses) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522) push(@mapped_emails, mailmap_email($line));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) merge_by_realname(@mapped_emails) if ($email_use_mailmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) return @mapped_emails;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) sub merge_by_realname {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) my %address_map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) my (@emails) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) foreach my $email (@emails) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) my ($name, $address) = parse_email($email);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) if (exists $address_map{$name}) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) $address = $address_map{$name};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) $email = format_email($name, $address, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) $address_map{$name} = $address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) sub git_execute_cmd {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) my ($cmd) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) my @lines = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) my $output = `$cmd`;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) $output =~ s/^\s*//gm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) @lines = split("\n", $output);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) return @lines;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) sub hg_execute_cmd {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) my ($cmd) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) my @lines = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) my $output = `$cmd`;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559) @lines = split("\n", $output);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) return @lines;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564) sub extract_formatted_signatures {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) my (@signature_lines) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) my @type = @signature_lines;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) s/\s*(.*):.*/$1/ for (@type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) # cut -f2- -d":"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) s/\s*.*:\s*(.+)\s*/$1/ for (@signature_lines);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574) ## Reformat email addresses (with names) to avoid badly written signatures
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) foreach my $signer (@signature_lines) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) $signer = deduplicate_email($signer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) return (\@type, \@signature_lines);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) sub vcs_find_signers {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584) my ($cmd, $file) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585) my $commits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586) my @lines = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) my @signatures = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588) my @authors = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589) my @stats = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591) @lines = &{$VCS_cmds{"execute_cmd"}}($cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593) my $pattern = $VCS_cmds{"commit_pattern"};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594) my $author_pattern = $VCS_cmds{"author_pattern"};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595) my $stat_pattern = $VCS_cmds{"stat_pattern"};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597) $stat_pattern =~ s/(\$\w+)/$1/eeg; #interpolate $stat_pattern
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599) $commits = grep(/$pattern/, @lines); # of commits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) @authors = grep(/$author_pattern/, @lines);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) @signatures = grep(/^[ \t]*${signature_pattern}.*\@.*$/, @lines);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603) @stats = grep(/$stat_pattern/, @lines);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605) # print("stats: <@stats>\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607) return (0, \@signatures, \@authors, \@stats) if !@signatures;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609) save_commits_by_author(@lines) if ($interactive);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610) save_commits_by_signer(@lines) if ($interactive);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612) if (!$email_git_penguin_chiefs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613) @signatures = grep(!/${penguin_chiefs}/i, @signatures);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616) my ($author_ref, $authors_ref) = extract_formatted_signatures(@authors);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617) my ($types_ref, $signers_ref) = extract_formatted_signatures(@signatures);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619) return ($commits, $signers_ref, $authors_ref, \@stats);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622) sub vcs_find_author {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623) my ($cmd) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624) my @lines = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626) @lines = &{$VCS_cmds{"execute_cmd"}}($cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) if (!$email_git_penguin_chiefs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) @lines = grep(!/${penguin_chiefs}/i, @lines);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632) return @lines if !@lines;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634) my @authors = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635) foreach my $line (@lines) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636) if ($line =~ m/$VCS_cmds{"author_pattern"}/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637) my $author = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638) my ($name, $address) = parse_email($author);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639) $author = format_email($name, $address, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640) push(@authors, $author);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644) save_commits_by_author(@lines) if ($interactive);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645) save_commits_by_signer(@lines) if ($interactive);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647) return @authors;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650) sub vcs_save_commits {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651) my ($cmd) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652) my @lines = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653) my @commits = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655) @lines = &{$VCS_cmds{"execute_cmd"}}($cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657) foreach my $line (@lines) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658) if ($line =~ m/$VCS_cmds{"blame_commit_pattern"}/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659) push(@commits, $1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1660) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1661) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1662)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1663) return @commits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1664) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1665)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1666) sub vcs_blame {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1667) my ($file) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1668) my $cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1669) my @commits = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1670)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1671) return @commits if (!(-f $file));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1672)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1673) if (@range && $VCS_cmds{"blame_range_cmd"} eq "") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1674) my @all_commits = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1675)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1676) $cmd = $VCS_cmds{"blame_file_cmd"};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1677) $cmd =~ s/(\$\w+)/$1/eeg; #interpolate $cmd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1678) @all_commits = vcs_save_commits($cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1679)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1680) foreach my $file_range_diff (@range) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1681) next if (!($file_range_diff =~ m/(.+):(.+):(.+)/));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1682) my $diff_file = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1683) my $diff_start = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1684) my $diff_length = $3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1685) next if ("$file" ne "$diff_file");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1686) for (my $i = $diff_start; $i < $diff_start + $diff_length; $i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1687) push(@commits, $all_commits[$i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1688) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1689) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1690) } elsif (@range) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1691) foreach my $file_range_diff (@range) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1692) next if (!($file_range_diff =~ m/(.+):(.+):(.+)/));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1693) my $diff_file = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1694) my $diff_start = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1695) my $diff_length = $3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1696) next if ("$file" ne "$diff_file");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1697) $cmd = $VCS_cmds{"blame_range_cmd"};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1698) $cmd =~ s/(\$\w+)/$1/eeg; #interpolate $cmd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1699) push(@commits, vcs_save_commits($cmd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1700) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1701) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1702) $cmd = $VCS_cmds{"blame_file_cmd"};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1703) $cmd =~ s/(\$\w+)/$1/eeg; #interpolate $cmd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1704) @commits = vcs_save_commits($cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1705) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1706)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1707) foreach my $commit (@commits) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1708) $commit =~ s/^\^//g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1709) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1710)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1711) return @commits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1712) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1713)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1714) my $printed_novcs = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1715) sub vcs_exists {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1716) %VCS_cmds = %VCS_cmds_git;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1717) return 1 if eval $VCS_cmds{"available"};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1718) %VCS_cmds = %VCS_cmds_hg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1719) return 2 if eval $VCS_cmds{"available"};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1720) %VCS_cmds = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1721) if (!$printed_novcs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1722) warn("$P: No supported VCS found. Add --nogit to options?\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1723) warn("Using a git repository produces better results.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1724) warn("Try Linus Torvalds' latest git repository using:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1725) warn("git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1726) $printed_novcs = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1727) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1728) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1729) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1730)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1731) sub vcs_is_git {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1732) vcs_exists();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1733) return $vcs_used == 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1734) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1735)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1736) sub vcs_is_hg {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1737) return $vcs_used == 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1738) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1739)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1740) sub vcs_add_commit_signers {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1741) return if (!vcs_exists());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1742)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1743) my ($commit, $desc) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1744) my $commit_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1745) my $commit_authors_ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1746) my $commit_signers_ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1747) my $stats_ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1748) my @commit_authors = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1749) my @commit_signers = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1750) my $cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1751)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1752) $cmd = $VCS_cmds{"find_commit_signers_cmd"};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1753) $cmd =~ s/(\$\w+)/$1/eeg; #substitute variables in $cmd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1754)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1755) ($commit_count, $commit_signers_ref, $commit_authors_ref, $stats_ref) = vcs_find_signers($cmd, "");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1756) @commit_authors = @{$commit_authors_ref} if defined $commit_authors_ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1757) @commit_signers = @{$commit_signers_ref} if defined $commit_signers_ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1758)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1759) foreach my $signer (@commit_signers) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1760) $signer = deduplicate_email($signer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1761) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1762)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1763) vcs_assign($desc, 1, @commit_signers);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1764) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1765)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1766) sub interactive_get_maintainers {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1767) my ($list_ref) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1768) my @list = @$list_ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1769)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1770) vcs_exists();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1771)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1772) my %selected;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1773) my %authored;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1774) my %signed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1775) my $count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1776) my $maintained = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1777) foreach my $entry (@list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1778) $maintained = 1 if ($entry->[1] =~ /^(maintainer|supporter)/i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1779) $selected{$count} = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1780) $authored{$count} = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1781) $signed{$count} = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1782) $count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1783) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1784)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1785) #menu loop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1786) my $done = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1787) my $print_options = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1788) my $redraw = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1789) while (!$done) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1790) $count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1791) if ($redraw) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1792) printf STDERR "\n%1s %2s %-65s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1793) "*", "#", "email/list and role:stats";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1794) if ($email_git ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1795) ($email_git_fallback && !$maintained) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1796) $email_git_blame) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1797) print STDERR "auth sign";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1798) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1799) print STDERR "\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1800) foreach my $entry (@list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1801) my $email = $entry->[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1802) my $role = $entry->[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1803) my $sel = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1804) $sel = "*" if ($selected{$count});
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1805) my $commit_author = $commit_author_hash{$email};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1806) my $commit_signer = $commit_signer_hash{$email};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1807) my $authored = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1808) my $signed = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1809) $authored++ for (@{$commit_author});
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1810) $signed++ for (@{$commit_signer});
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1811) printf STDERR "%1s %2d %-65s", $sel, $count + 1, $email;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1812) printf STDERR "%4d %4d", $authored, $signed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1813) if ($authored > 0 || $signed > 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1814) printf STDERR "\n %s\n", $role;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1815) if ($authored{$count}) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1816) my $commit_author = $commit_author_hash{$email};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1817) foreach my $ref (@{$commit_author}) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1818) print STDERR " Author: @{$ref}[1]\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1819) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1820) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1821) if ($signed{$count}) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1822) my $commit_signer = $commit_signer_hash{$email};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1823) foreach my $ref (@{$commit_signer}) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1824) print STDERR " @{$ref}[2]: @{$ref}[1]\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1825) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1826) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1827)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1828) $count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1829) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1830) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1831) my $date_ref = \$email_git_since;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1832) $date_ref = \$email_hg_since if (vcs_is_hg());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1833) if ($print_options) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1834) $print_options = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1835) if (vcs_exists()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1836) print STDERR <<EOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1837)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1838) Version Control options:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1839) g use git history [$email_git]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1840) gf use git-fallback [$email_git_fallback]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1841) b use git blame [$email_git_blame]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1842) bs use blame signatures [$email_git_blame_signatures]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1843) c# minimum commits [$email_git_min_signatures]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1844) %# min percent [$email_git_min_percent]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1845) d# history to use [$$date_ref]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1846) x# max maintainers [$email_git_max_maintainers]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1847) t all signature types [$email_git_all_signature_types]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1848) m use .mailmap [$email_use_mailmap]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1849) EOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1850) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1851) print STDERR <<EOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1852)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1853) Additional options:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1854) 0 toggle all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1855) tm toggle maintainers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1856) tg toggle git entries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1857) tl toggle open list entries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1858) ts toggle subscriber list entries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1859) f emails in file [$email_file_emails]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1860) k keywords in file [$keywords]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1861) r remove duplicates [$email_remove_duplicates]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1862) p# pattern match depth [$pattern_depth]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1863) EOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1864) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1865) print STDERR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1866) "\n#(toggle), A#(author), S#(signed) *(all), ^(none), O(options), Y(approve): ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1867)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1868) my $input = <STDIN>;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1869) chomp($input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1870)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1871) $redraw = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1872) my $rerun = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1873) my @wish = split(/[, ]+/, $input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1874) foreach my $nr (@wish) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1875) $nr = lc($nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1876) my $sel = substr($nr, 0, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1877) my $str = substr($nr, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1878) my $val = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1879) $val = $1 if $str =~ /^(\d+)$/;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1880)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1881) if ($sel eq "y") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1882) $interactive = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1883) $done = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1884) $output_rolestats = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1885) $output_roles = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1886) last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1887) } elsif ($nr =~ /^\d+$/ && $nr > 0 && $nr <= $count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1888) $selected{$nr - 1} = !$selected{$nr - 1};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1889) } elsif ($sel eq "*" || $sel eq '^') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1890) my $toggle = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1891) $toggle = 1 if ($sel eq '*');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1892) for (my $i = 0; $i < $count; $i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1893) $selected{$i} = $toggle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1894) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1895) } elsif ($sel eq "0") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1896) for (my $i = 0; $i < $count; $i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1897) $selected{$i} = !$selected{$i};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1898) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1899) } elsif ($sel eq "t") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1900) if (lc($str) eq "m") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1901) for (my $i = 0; $i < $count; $i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1902) $selected{$i} = !$selected{$i}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1903) if ($list[$i]->[1] =~ /^(maintainer|supporter)/i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1904) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1905) } elsif (lc($str) eq "g") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1906) for (my $i = 0; $i < $count; $i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1907) $selected{$i} = !$selected{$i}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1908) if ($list[$i]->[1] =~ /^(author|commit|signer)/i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1909) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1910) } elsif (lc($str) eq "l") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1911) for (my $i = 0; $i < $count; $i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1912) $selected{$i} = !$selected{$i}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1913) if ($list[$i]->[1] =~ /^(open list)/i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1914) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1915) } elsif (lc($str) eq "s") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1916) for (my $i = 0; $i < $count; $i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1917) $selected{$i} = !$selected{$i}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1918) if ($list[$i]->[1] =~ /^(subscriber list)/i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1919) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1920) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1921) } elsif ($sel eq "a") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1922) if ($val > 0 && $val <= $count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1923) $authored{$val - 1} = !$authored{$val - 1};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1924) } elsif ($str eq '*' || $str eq '^') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1925) my $toggle = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1926) $toggle = 1 if ($str eq '*');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1927) for (my $i = 0; $i < $count; $i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1928) $authored{$i} = $toggle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1929) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1930) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1931) } elsif ($sel eq "s") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1932) if ($val > 0 && $val <= $count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1933) $signed{$val - 1} = !$signed{$val - 1};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1934) } elsif ($str eq '*' || $str eq '^') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1935) my $toggle = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1936) $toggle = 1 if ($str eq '*');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1937) for (my $i = 0; $i < $count; $i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1938) $signed{$i} = $toggle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1939) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1940) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1941) } elsif ($sel eq "o") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1942) $print_options = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1943) $redraw = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1944) } elsif ($sel eq "g") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1945) if ($str eq "f") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1946) bool_invert(\$email_git_fallback);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1947) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1948) bool_invert(\$email_git);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1949) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1950) $rerun = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1951) } elsif ($sel eq "b") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1952) if ($str eq "s") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1953) bool_invert(\$email_git_blame_signatures);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1954) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1955) bool_invert(\$email_git_blame);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1956) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1957) $rerun = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1958) } elsif ($sel eq "c") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1959) if ($val > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1960) $email_git_min_signatures = $val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1961) $rerun = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1962) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1963) } elsif ($sel eq "x") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1964) if ($val > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1965) $email_git_max_maintainers = $val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1966) $rerun = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1967) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1968) } elsif ($sel eq "%") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1969) if ($str ne "" && $val >= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1970) $email_git_min_percent = $val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1971) $rerun = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1972) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1973) } elsif ($sel eq "d") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1974) if (vcs_is_git()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1975) $email_git_since = $str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1976) } elsif (vcs_is_hg()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1977) $email_hg_since = $str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1978) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1979) $rerun = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1980) } elsif ($sel eq "t") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1981) bool_invert(\$email_git_all_signature_types);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1982) $rerun = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1983) } elsif ($sel eq "f") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1984) bool_invert(\$email_file_emails);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1985) $rerun = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1986) } elsif ($sel eq "r") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1987) bool_invert(\$email_remove_duplicates);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1988) $rerun = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1989) } elsif ($sel eq "m") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1990) bool_invert(\$email_use_mailmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1991) read_mailmap();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1992) $rerun = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1993) } elsif ($sel eq "k") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1994) bool_invert(\$keywords);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1995) $rerun = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1996) } elsif ($sel eq "p") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1997) if ($str ne "" && $val >= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1998) $pattern_depth = $val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1999) $rerun = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2000) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2001) } elsif ($sel eq "h" || $sel eq "?") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2002) print STDERR <<EOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2003)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2004) Interactive mode allows you to select the various maintainers, submitters,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2005) commit signers and mailing lists that could be CC'd on a patch.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2006)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2007) Any *'d entry is selected.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2008)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2009) If you have git or hg installed, you can choose to summarize the commit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2010) history of files in the patch. Also, each line of the current file can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2011) be matched to its commit author and that commits signers with blame.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2012)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2013) Various knobs exist to control the length of time for active commit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2014) tracking, the maximum number of commit authors and signers to add,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2015) and such.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2016)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2017) Enter selections at the prompt until you are satisfied that the selected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2018) maintainers are appropriate. You may enter multiple selections separated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2019) by either commas or spaces.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2020)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2021) EOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2022) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2023) print STDERR "invalid option: '$nr'\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2024) $redraw = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2025) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2026) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2027) if ($rerun) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2028) print STDERR "git-blame can be very slow, please have patience..."
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2029) if ($email_git_blame);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2030) goto &get_maintainers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2031) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2032) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2033)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2034) #drop not selected entries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2035) $count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2036) my @new_emailto = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2037) foreach my $entry (@list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2038) if ($selected{$count}) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2039) push(@new_emailto, $list[$count]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2040) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2041) $count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2042) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2043) return @new_emailto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2044) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2045)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2046) sub bool_invert {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2047) my ($bool_ref) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2048)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2049) if ($$bool_ref) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2050) $$bool_ref = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2051) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2052) $$bool_ref = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2053) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2054) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2055)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2056) sub deduplicate_email {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2057) my ($email) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2058)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2059) my $matched = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2060) my ($name, $address) = parse_email($email);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2061) $email = format_email($name, $address, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2062) $email = mailmap_email($email);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2063)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2064) return $email if (!$email_remove_duplicates);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2065)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2066) ($name, $address) = parse_email($email);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2067)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2068) if ($name ne "" && $deduplicate_name_hash{lc($name)}) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2069) $name = $deduplicate_name_hash{lc($name)}->[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2070) $address = $deduplicate_name_hash{lc($name)}->[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2071) $matched = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2072) } elsif ($deduplicate_address_hash{lc($address)}) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2073) $name = $deduplicate_address_hash{lc($address)}->[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2074) $address = $deduplicate_address_hash{lc($address)}->[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2075) $matched = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2076) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2077) if (!$matched) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2078) $deduplicate_name_hash{lc($name)} = [ $name, $address ];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2079) $deduplicate_address_hash{lc($address)} = [ $name, $address ];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2080) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2081) $email = format_email($name, $address, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2082) $email = mailmap_email($email);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2083) return $email;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2084) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2085)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2086) sub save_commits_by_author {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2087) my (@lines) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2088)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2089) my @authors = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2090) my @commits = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2091) my @subjects = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2092)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2093) foreach my $line (@lines) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2094) if ($line =~ m/$VCS_cmds{"author_pattern"}/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2095) my $author = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2096) $author = deduplicate_email($author);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2097) push(@authors, $author);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2098) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2099) push(@commits, $1) if ($line =~ m/$VCS_cmds{"commit_pattern"}/);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2100) push(@subjects, $1) if ($line =~ m/$VCS_cmds{"subject_pattern"}/);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2103) for (my $i = 0; $i < @authors; $i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2104) my $exists = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2105) foreach my $ref(@{$commit_author_hash{$authors[$i]}}) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2106) if (@{$ref}[0] eq $commits[$i] &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2107) @{$ref}[1] eq $subjects[$i]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2108) $exists = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2109) last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2110) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2112) if (!$exists) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2113) push(@{$commit_author_hash{$authors[$i]}},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2114) [ ($commits[$i], $subjects[$i]) ]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2115) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2117) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2119) sub save_commits_by_signer {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2120) my (@lines) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2122) my $commit = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2123) my $subject = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2125) foreach my $line (@lines) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2126) $commit = $1 if ($line =~ m/$VCS_cmds{"commit_pattern"}/);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2127) $subject = $1 if ($line =~ m/$VCS_cmds{"subject_pattern"}/);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2128) if ($line =~ /^[ \t]*${signature_pattern}.*\@.*$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2129) my @signatures = ($line);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2130) my ($types_ref, $signers_ref) = extract_formatted_signatures(@signatures);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2131) my @types = @$types_ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2132) my @signers = @$signers_ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2134) my $type = $types[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2135) my $signer = $signers[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2137) $signer = deduplicate_email($signer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2139) my $exists = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2140) foreach my $ref(@{$commit_signer_hash{$signer}}) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2141) if (@{$ref}[0] eq $commit &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2142) @{$ref}[1] eq $subject &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2143) @{$ref}[2] eq $type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2144) $exists = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2145) last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2147) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2148) if (!$exists) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2149) push(@{$commit_signer_hash{$signer}},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2150) [ ($commit, $subject, $type) ]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2151) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2152) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2153) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2154) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2156) sub vcs_assign {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2157) my ($role, $divisor, @lines) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2159) my %hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2160) my $count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2162) return if (@lines <= 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2164) if ($divisor <= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2165) warn("Bad divisor in " . (caller(0))[3] . ": $divisor\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2166) $divisor = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2167) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2169) @lines = mailmap(@lines);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2171) return if (@lines <= 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2173) @lines = sort(@lines);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2175) # uniq -c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2176) $hash{$_}++ for @lines;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2178) # sort -rn
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2179) foreach my $line (sort {$hash{$b} <=> $hash{$a}} keys %hash) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2180) my $sign_offs = $hash{$line};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2181) my $percent = $sign_offs * 100 / $divisor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2183) $percent = 100 if ($percent > 100);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2184) next if (ignore_email_address($line));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2185) $count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2186) last if ($sign_offs < $email_git_min_signatures ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2187) $count > $email_git_max_maintainers ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2188) $percent < $email_git_min_percent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2189) push_email_address($line, '');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2190) if ($output_rolestats) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2191) my $fmt_percent = sprintf("%.0f", $percent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2192) add_role($line, "$role:$sign_offs/$divisor=$fmt_percent%");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2193) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2194) add_role($line, $role);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2195) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2197) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2199) sub vcs_file_signoffs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2200) my ($file) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2202) my $authors_ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2203) my $signers_ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2204) my $stats_ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2205) my @authors = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2206) my @signers = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2207) my @stats = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2208) my $commits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2210) $vcs_used = vcs_exists();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2211) return if (!$vcs_used);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2213) my $cmd = $VCS_cmds{"find_signers_cmd"};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2214) $cmd =~ s/(\$\w+)/$1/eeg; # interpolate $cmd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2216) ($commits, $signers_ref, $authors_ref, $stats_ref) = vcs_find_signers($cmd, $file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2218) @signers = @{$signers_ref} if defined $signers_ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2219) @authors = @{$authors_ref} if defined $authors_ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2220) @stats = @{$stats_ref} if defined $stats_ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2222) # print("commits: <$commits>\nsigners:<@signers>\nauthors: <@authors>\nstats: <@stats>\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2224) foreach my $signer (@signers) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2225) $signer = deduplicate_email($signer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2226) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2228) vcs_assign("commit_signer", $commits, @signers);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2229) vcs_assign("authored", $commits, @authors);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2230) if ($#authors == $#stats) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2231) my $stat_pattern = $VCS_cmds{"stat_pattern"};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2232) $stat_pattern =~ s/(\$\w+)/$1/eeg; #interpolate $stat_pattern
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2234) my $added = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2235) my $deleted = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2236) for (my $i = 0; $i <= $#stats; $i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2237) if ($stats[$i] =~ /$stat_pattern/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2238) $added += $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2239) $deleted += $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2240) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2242) my @tmp_authors = uniq(@authors);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2243) foreach my $author (@tmp_authors) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2244) $author = deduplicate_email($author);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2245) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2246) @tmp_authors = uniq(@tmp_authors);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2247) my @list_added = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2248) my @list_deleted = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2249) foreach my $author (@tmp_authors) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2250) my $auth_added = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2251) my $auth_deleted = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2252) for (my $i = 0; $i <= $#stats; $i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2253) if ($author eq deduplicate_email($authors[$i]) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2254) $stats[$i] =~ /$stat_pattern/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2255) $auth_added += $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2256) $auth_deleted += $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2257) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2258) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2259) for (my $i = 0; $i < $auth_added; $i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2260) push(@list_added, $author);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2261) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2262) for (my $i = 0; $i < $auth_deleted; $i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2263) push(@list_deleted, $author);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2264) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2265) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2266) vcs_assign("added_lines", $added, @list_added);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2267) vcs_assign("removed_lines", $deleted, @list_deleted);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2269) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2271) sub vcs_file_blame {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2272) my ($file) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2274) my @signers = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2275) my @all_commits = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2276) my @commits = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2277) my $total_commits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2278) my $total_lines;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2280) $vcs_used = vcs_exists();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2281) return if (!$vcs_used);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2283) @all_commits = vcs_blame($file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2284) @commits = uniq(@all_commits);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2285) $total_commits = @commits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2286) $total_lines = @all_commits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2288) if ($email_git_blame_signatures) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2289) if (vcs_is_hg()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2290) my $commit_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2291) my $commit_authors_ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2292) my $commit_signers_ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2293) my $stats_ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2294) my @commit_authors = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2295) my @commit_signers = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2296) my $commit = join(" -r ", @commits);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2297) my $cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2299) $cmd = $VCS_cmds{"find_commit_signers_cmd"};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2300) $cmd =~ s/(\$\w+)/$1/eeg; #substitute variables in $cmd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2302) ($commit_count, $commit_signers_ref, $commit_authors_ref, $stats_ref) = vcs_find_signers($cmd, $file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2303) @commit_authors = @{$commit_authors_ref} if defined $commit_authors_ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2304) @commit_signers = @{$commit_signers_ref} if defined $commit_signers_ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2305)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2306) push(@signers, @commit_signers);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2307) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2308) foreach my $commit (@commits) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2309) my $commit_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2310) my $commit_authors_ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2311) my $commit_signers_ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2312) my $stats_ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2313) my @commit_authors = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2314) my @commit_signers = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2315) my $cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2316)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2317) $cmd = $VCS_cmds{"find_commit_signers_cmd"};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2318) $cmd =~ s/(\$\w+)/$1/eeg; #substitute variables in $cmd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2320) ($commit_count, $commit_signers_ref, $commit_authors_ref, $stats_ref) = vcs_find_signers($cmd, $file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2321) @commit_authors = @{$commit_authors_ref} if defined $commit_authors_ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2322) @commit_signers = @{$commit_signers_ref} if defined $commit_signers_ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2324) push(@signers, @commit_signers);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2325) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2326) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2327) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2329) if ($from_filename) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2330) if ($output_rolestats) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2331) my @blame_signers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2332) if (vcs_is_hg()) {{ # Double brace for last exit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2333) my $commit_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2334) my @commit_signers = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2335) @commits = uniq(@commits);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2336) @commits = sort(@commits);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2337) my $commit = join(" -r ", @commits);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2338) my $cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2340) $cmd = $VCS_cmds{"find_commit_author_cmd"};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2341) $cmd =~ s/(\$\w+)/$1/eeg; #substitute variables in $cmd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2343) my @lines = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2345) @lines = &{$VCS_cmds{"execute_cmd"}}($cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2346)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2347) if (!$email_git_penguin_chiefs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2348) @lines = grep(!/${penguin_chiefs}/i, @lines);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2349) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2351) last if !@lines;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2353) my @authors = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2354) foreach my $line (@lines) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2355) if ($line =~ m/$VCS_cmds{"author_pattern"}/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2356) my $author = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2357) $author = deduplicate_email($author);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2358) push(@authors, $author);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2359) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2360) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2362) save_commits_by_author(@lines) if ($interactive);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2363) save_commits_by_signer(@lines) if ($interactive);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2364)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2365) push(@signers, @authors);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2366) }}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2367) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2368) foreach my $commit (@commits) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2369) my $i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2370) my $cmd = $VCS_cmds{"find_commit_author_cmd"};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2371) $cmd =~ s/(\$\w+)/$1/eeg; #interpolate $cmd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2372) my @author = vcs_find_author($cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2373) next if !@author;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2375) my $formatted_author = deduplicate_email($author[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2377) my $count = grep(/$commit/, @all_commits);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2378) for ($i = 0; $i < $count ; $i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2379) push(@blame_signers, $formatted_author);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2380) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2381) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2382) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2383) if (@blame_signers) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2384) vcs_assign("authored lines", $total_lines, @blame_signers);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2385) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2386) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2387) foreach my $signer (@signers) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2388) $signer = deduplicate_email($signer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2389) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2390) vcs_assign("commits", $total_commits, @signers);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2391) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2392) foreach my $signer (@signers) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2393) $signer = deduplicate_email($signer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2394) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2395) vcs_assign("modified commits", $total_commits, @signers);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2396) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2397) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2398)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2399) sub vcs_file_exists {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2400) my ($file) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2401)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2402) my $exists;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2403)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2404) my $vcs_used = vcs_exists();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2405) return 0 if (!$vcs_used);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2407) my $cmd = $VCS_cmds{"file_exists_cmd"};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2408) $cmd =~ s/(\$\w+)/$1/eeg; # interpolate $cmd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2409) $cmd .= " 2>&1";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2410) $exists = &{$VCS_cmds{"execute_cmd"}}($cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2411)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2412) return 0 if ($? != 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2413)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2414) return $exists;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2415) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2416)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2417) sub vcs_list_files {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2418) my ($file) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2420) my @lsfiles = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2421)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2422) my $vcs_used = vcs_exists();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2423) return 0 if (!$vcs_used);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2425) my $cmd = $VCS_cmds{"list_files_cmd"};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2426) $cmd =~ s/(\$\w+)/$1/eeg; # interpolate $cmd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2427) @lsfiles = &{$VCS_cmds{"execute_cmd"}}($cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2428)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2429) return () if ($? != 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2431) return @lsfiles;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2432) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2433)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2434) sub uniq {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2435) my (@parms) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2437) my %saw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2438) @parms = grep(!$saw{$_}++, @parms);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2439) return @parms;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2440) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2442) sub sort_and_uniq {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2443) my (@parms) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2444)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2445) my %saw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2446) @parms = sort @parms;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2447) @parms = grep(!$saw{$_}++, @parms);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2448) return @parms;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2449) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2450)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2451) sub clean_file_emails {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2452) my (@file_emails) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2453) my @fmt_emails = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2454)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2455) foreach my $email (@file_emails) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2456) $email =~ s/[\(\<\{]{0,1}([A-Za-z0-9_\.\+-]+\@[A-Za-z0-9\.-]+)[\)\>\}]{0,1}/\<$1\>/g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2457) my ($name, $address) = parse_email($email);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2458) if ($name eq '"[,\.]"') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2459) $name = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2460) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2461)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2462) my @nw = split(/[^A-Za-zÀ-ÿ\'\,\.\+-]/, $name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2463) if (@nw > 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2464) my $first = $nw[@nw - 3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2465) my $middle = $nw[@nw - 2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2466) my $last = $nw[@nw - 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2468) if (((length($first) == 1 && $first =~ m/[A-Za-z]/) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2469) (length($first) == 2 && substr($first, -1) eq ".")) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2470) (length($middle) == 1 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2471) (length($middle) == 2 && substr($middle, -1) eq "."))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2472) $name = "$first $middle $last";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2473) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2474) $name = "$middle $last";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2475) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2476) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2477)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2478) if (substr($name, -1) =~ /[,\.]/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2479) $name = substr($name, 0, length($name) - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2480) } elsif (substr($name, -2) =~ /[,\.]"/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2481) $name = substr($name, 0, length($name) - 2) . '"';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2482) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2483)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2484) if (substr($name, 0, 1) =~ /[,\.]/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2485) $name = substr($name, 1, length($name) - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2486) } elsif (substr($name, 0, 2) =~ /"[,\.]/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2487) $name = '"' . substr($name, 2, length($name) - 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2488) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2490) my $fmt_email = format_email($name, $address, $email_usename);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2491) push(@fmt_emails, $fmt_email);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2492) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2493) return @fmt_emails;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2494) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2495)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2496) sub merge_email {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2497) my @lines;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2498) my %saw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2499)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2500) for (@_) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2501) my ($address, $role) = @$_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2502) if (!$saw{$address}) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2503) if ($output_roles) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2504) push(@lines, "$address ($role)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2505) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2506) push(@lines, $address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2507) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2508) $saw{$address} = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2509) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2510) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2511)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2512) return @lines;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2513) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2514)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2515) sub output {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2516) my (@parms) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2517)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2518) if ($output_multiline) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2519) foreach my $line (@parms) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2520) print("${line}\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2521) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2522) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2523) print(join($output_separator, @parms));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2524) print("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2525) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2526) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2527)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2528) my $rfc822re;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2529)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2530) sub make_rfc822re {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2531) # Basic lexical tokens are specials, domain_literal, quoted_string, atom, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2532) # comment. We must allow for rfc822_lwsp (or comments) after each of these.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2533) # This regexp will only work on addresses which have had comments stripped
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2534) # and replaced with rfc822_lwsp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2535)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2536) my $specials = '()<>@,;:\\\\".\\[\\]';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2537) my $controls = '\\000-\\037\\177';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2538)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2539) my $dtext = "[^\\[\\]\\r\\\\]";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2540) my $domain_literal = "\\[(?:$dtext|\\\\.)*\\]$rfc822_lwsp*";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2541)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2542) my $quoted_string = "\"(?:[^\\\"\\r\\\\]|\\\\.|$rfc822_lwsp)*\"$rfc822_lwsp*";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2543)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2544) # Use zero-width assertion to spot the limit of an atom. A simple
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2545) # $rfc822_lwsp* causes the regexp engine to hang occasionally.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2546) my $atom = "[^$specials $controls]+(?:$rfc822_lwsp+|\\Z|(?=[\\[\"$specials]))";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2547) my $word = "(?:$atom|$quoted_string)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2548) my $localpart = "$word(?:\\.$rfc822_lwsp*$word)*";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2549)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2550) my $sub_domain = "(?:$atom|$domain_literal)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2551) my $domain = "$sub_domain(?:\\.$rfc822_lwsp*$sub_domain)*";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2552)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2553) my $addr_spec = "$localpart\@$rfc822_lwsp*$domain";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2554)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2555) my $phrase = "$word*";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2556) my $route = "(?:\@$domain(?:,\@$rfc822_lwsp*$domain)*:$rfc822_lwsp*)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2557) my $route_addr = "\\<$rfc822_lwsp*$route?$addr_spec\\>$rfc822_lwsp*";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2558) my $mailbox = "(?:$addr_spec|$phrase$route_addr)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2559)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2560) my $group = "$phrase:$rfc822_lwsp*(?:$mailbox(?:,\\s*$mailbox)*)?;\\s*";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2561) my $address = "(?:$mailbox|$group)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2562)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2563) return "$rfc822_lwsp*$address";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2564) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2565)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2566) sub rfc822_strip_comments {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2567) my $s = shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2568) # Recursively remove comments, and replace with a single space. The simpler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2569) # regexps in the Email Addressing FAQ are imperfect - they will miss escaped
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2570) # chars in atoms, for example.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2571)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2572) while ($s =~ s/^((?:[^"\\]|\\.)*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2573) (?:"(?:[^"\\]|\\.)*"(?:[^"\\]|\\.)*)*)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2574) \((?:[^()\\]|\\.)*\)/$1 /osx) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2575) return $s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2576) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2577)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2578) # valid: returns true if the parameter is an RFC822 valid address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2579) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2580) sub rfc822_valid {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2581) my $s = rfc822_strip_comments(shift);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2582)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2583) if (!$rfc822re) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2584) $rfc822re = make_rfc822re();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2585) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2586)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2587) return $s =~ m/^$rfc822re$/so && $s =~ m/^$rfc822_char*$/;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2588) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2589)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2590) # validlist: In scalar context, returns true if the parameter is an RFC822
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2591) # valid list of addresses.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2592) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2593) # In list context, returns an empty list on failure (an invalid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2594) # address was found); otherwise a list whose first element is the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2595) # number of addresses found and whose remaining elements are the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2596) # addresses. This is needed to disambiguate failure (invalid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2597) # from success with no addresses found, because an empty string is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2598) # a valid list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2599)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2600) sub rfc822_validlist {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2601) my $s = rfc822_strip_comments(shift);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2602)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2603) if (!$rfc822re) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2604) $rfc822re = make_rfc822re();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2605) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2606) # * null list items are valid according to the RFC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2607) # * the '1' business is to aid in distinguishing failure from no results
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2608)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2609) my @r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2610) if ($s =~ m/^(?:$rfc822re)?(?:,(?:$rfc822re)?)*$/so &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2611) $s =~ m/^$rfc822_char*$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2612) while ($s =~ m/(?:^|,$rfc822_lwsp*)($rfc822re)/gos) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2613) push(@r, $1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2614) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2615) return wantarray ? (scalar(@r), @r) : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2616) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2617) return wantarray ? () : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2618) }