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