diff options
Diffstat (limited to 'scripts/get_maintainer.pl')
-rwxr-xr-x | scripts/get_maintainer.pl | 60 |
1 files changed, 57 insertions, 3 deletions
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl index b2281982f52f..a91ae6318403 100755 --- a/scripts/get_maintainer.pl +++ b/scripts/get_maintainer.pl | |||
@@ -13,7 +13,7 @@ | |||
13 | use strict; | 13 | use strict; |
14 | 14 | ||
15 | my $P = $0; | 15 | my $P = $0; |
16 | my $V = '0.24'; | 16 | my $V = '0.25'; |
17 | 17 | ||
18 | use Getopt::Long qw(:config no_auto_abbrev); | 18 | use Getopt::Long qw(:config no_auto_abbrev); |
19 | 19 | ||
@@ -88,6 +88,7 @@ my %VCS_cmds_git = ( | |||
88 | "available" => '(which("git") ne "") && (-d ".git")', | 88 | "available" => '(which("git") ne "") && (-d ".git")', |
89 | "find_signers_cmd" => "git log --no-color --since=\$email_git_since -- \$file", | 89 | "find_signers_cmd" => "git log --no-color --since=\$email_git_since -- \$file", |
90 | "find_commit_signers_cmd" => "git log --no-color -1 \$commit", | 90 | "find_commit_signers_cmd" => "git log --no-color -1 \$commit", |
91 | "find_commit_author_cmd" => "git log -1 --format=\"%an <%ae>\" \$commit", | ||
91 | "blame_range_cmd" => "git blame -l -L \$diff_start,+\$diff_length \$file", | 92 | "blame_range_cmd" => "git blame -l -L \$diff_start,+\$diff_length \$file", |
92 | "blame_file_cmd" => "git blame -l \$file", | 93 | "blame_file_cmd" => "git blame -l \$file", |
93 | "commit_pattern" => "^commit [0-9a-f]{40,40}", | 94 | "commit_pattern" => "^commit [0-9a-f]{40,40}", |
@@ -101,6 +102,7 @@ my %VCS_cmds_hg = ( | |||
101 | "hg log --date=\$email_hg_since" . | 102 | "hg log --date=\$email_hg_since" . |
102 | " --template='commit {node}\\n{desc}\\n' -- \$file", | 103 | " --template='commit {node}\\n{desc}\\n' -- \$file", |
103 | "find_commit_signers_cmd" => "hg log --template='{desc}\\n' -r \$commit", | 104 | "find_commit_signers_cmd" => "hg log --template='{desc}\\n' -r \$commit", |
105 | "find_commit_author_cmd" => "hg log -l 1 --template='{author}\\n' -r \$commit", | ||
104 | "blame_range_cmd" => "", # not supported | 106 | "blame_range_cmd" => "", # not supported |
105 | "blame_file_cmd" => "hg blame -c \$file", | 107 | "blame_file_cmd" => "hg blame -c \$file", |
106 | "commit_pattern" => "^commit [0-9a-f]{40,40}", | 108 | "commit_pattern" => "^commit [0-9a-f]{40,40}", |
@@ -1014,6 +1016,9 @@ sub vcs_find_signers { | |||
1014 | if (!$email_git_penguin_chiefs) { | 1016 | if (!$email_git_penguin_chiefs) { |
1015 | @lines = grep(!/${penguin_chiefs}/i, @lines); | 1017 | @lines = grep(!/${penguin_chiefs}/i, @lines); |
1016 | } | 1018 | } |
1019 | |||
1020 | return (0, @lines) if !@lines; | ||
1021 | |||
1017 | # cut -f2- -d":" | 1022 | # cut -f2- -d":" |
1018 | s/.*:\s*(.+)\s*/$1/ for (@lines); | 1023 | s/.*:\s*(.+)\s*/$1/ for (@lines); |
1019 | 1024 | ||
@@ -1027,6 +1032,28 @@ sub vcs_find_signers { | |||
1027 | return ($commits, @lines); | 1032 | return ($commits, @lines); |
1028 | } | 1033 | } |
1029 | 1034 | ||
1035 | sub vcs_find_author { | ||
1036 | my ($cmd) = @_; | ||
1037 | my @lines = (); | ||
1038 | |||
1039 | @lines = &{$VCS_cmds{"execute_cmd"}}($cmd); | ||
1040 | |||
1041 | if (!$email_git_penguin_chiefs) { | ||
1042 | @lines = grep(!/${penguin_chiefs}/i, @lines); | ||
1043 | } | ||
1044 | |||
1045 | return @lines if !@lines; | ||
1046 | |||
1047 | ## Reformat email addresses (with names) to avoid badly written signatures | ||
1048 | |||
1049 | foreach my $line (@lines) { | ||
1050 | my ($name, $address) = parse_email($line); | ||
1051 | $line = format_email($name, $address, 1); | ||
1052 | } | ||
1053 | |||
1054 | return @lines; | ||
1055 | } | ||
1056 | |||
1030 | sub vcs_save_commits { | 1057 | sub vcs_save_commits { |
1031 | my ($cmd) = @_; | 1058 | my ($cmd) = @_; |
1032 | my @lines = (); | 1059 | my @lines = (); |
@@ -1084,6 +1111,10 @@ sub vcs_blame { | |||
1084 | @commits = vcs_save_commits($cmd); | 1111 | @commits = vcs_save_commits($cmd); |
1085 | } | 1112 | } |
1086 | 1113 | ||
1114 | foreach my $commit (@commits) { | ||
1115 | $commit =~ s/^\^//g; | ||
1116 | } | ||
1117 | |||
1087 | return @commits; | 1118 | return @commits; |
1088 | } | 1119 | } |
1089 | 1120 | ||
@@ -1121,6 +1152,8 @@ sub vcs_assign { | |||
1121 | @lines = mailmap(@lines); | 1152 | @lines = mailmap(@lines); |
1122 | } | 1153 | } |
1123 | 1154 | ||
1155 | return if (@lines <= 0); | ||
1156 | |||
1124 | @lines = sort(@lines); | 1157 | @lines = sort(@lines); |
1125 | 1158 | ||
1126 | # uniq -c | 1159 | # uniq -c |
@@ -1165,14 +1198,17 @@ sub vcs_file_blame { | |||
1165 | my ($file) = @_; | 1198 | my ($file) = @_; |
1166 | 1199 | ||
1167 | my @signers = (); | 1200 | my @signers = (); |
1201 | my @all_commits = (); | ||
1168 | my @commits = (); | 1202 | my @commits = (); |
1169 | my $total_commits; | 1203 | my $total_commits; |
1204 | my $total_lines; | ||
1170 | 1205 | ||
1171 | return if (!vcs_exists()); | 1206 | return if (!vcs_exists()); |
1172 | 1207 | ||
1173 | @commits = vcs_blame($file); | 1208 | @all_commits = vcs_blame($file); |
1174 | @commits = uniq(@commits); | 1209 | @commits = uniq(@all_commits); |
1175 | $total_commits = @commits; | 1210 | $total_commits = @commits; |
1211 | $total_lines = @all_commits; | ||
1176 | 1212 | ||
1177 | foreach my $commit (@commits) { | 1213 | foreach my $commit (@commits) { |
1178 | my $commit_count; | 1214 | my $commit_count; |
@@ -1182,10 +1218,28 @@ sub vcs_file_blame { | |||
1182 | $cmd =~ s/(\$\w+)/$1/eeg; #interpolate $cmd | 1218 | $cmd =~ s/(\$\w+)/$1/eeg; #interpolate $cmd |
1183 | 1219 | ||
1184 | ($commit_count, @commit_signers) = vcs_find_signers($cmd); | 1220 | ($commit_count, @commit_signers) = vcs_find_signers($cmd); |
1221 | |||
1185 | push(@signers, @commit_signers); | 1222 | push(@signers, @commit_signers); |
1186 | } | 1223 | } |
1187 | 1224 | ||
1188 | if ($from_filename) { | 1225 | if ($from_filename) { |
1226 | if ($output_rolestats) { | ||
1227 | my @blame_signers; | ||
1228 | foreach my $commit (@commits) { | ||
1229 | my $i; | ||
1230 | my $cmd = $VCS_cmds{"find_commit_author_cmd"}; | ||
1231 | $cmd =~ s/(\$\w+)/$1/eeg; #interpolate $cmd | ||
1232 | my @author = vcs_find_author($cmd); | ||
1233 | next if !@author; | ||
1234 | my $count = grep(/$commit/, @all_commits); | ||
1235 | for ($i = 0; $i < $count ; $i++) { | ||
1236 | push(@blame_signers, $author[0]); | ||
1237 | } | ||
1238 | } | ||
1239 | if (@blame_signers) { | ||
1240 | vcs_assign("authored lines", $total_lines, @blame_signers); | ||
1241 | } | ||
1242 | } | ||
1189 | vcs_assign("commits", $total_commits, @signers); | 1243 | vcs_assign("commits", $total_commits, @signers); |
1190 | } else { | 1244 | } else { |
1191 | vcs_assign("modified commits", $total_commits, @signers); | 1245 | vcs_assign("modified commits", $total_commits, @signers); |