diff options
author | Joe Perches <joe@perches.com> | 2010-10-26 17:22:51 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-26 19:52:16 -0400 |
commit | 63ab52db5ba7f362266cfed03109387ca73e5eb5 (patch) | |
tree | cc4beeaf6d860ba0d29caea4e31344d5be915fb1 /scripts/get_maintainer.pl | |
parent | b903c0b8899b46829a9b80ba55b61079b35940ec (diff) |
scripts/get_maintainer.pl: Add --git-blame --rolestats "Authored lines" information
When options --git-blame and --rolestats are specified, add
the maintainers with the qualifying --git-min-percent amount
of lines authored of the complete file. Does not add more
authors than specified by --git-max-maintainers.
For anyone using hg, this option works but is _very_ slow.
It's orders of magnitude slower than git slow.
The get_maintainer.pl version was incremented to 0.25.
This can be used with or without --git.
For instance:
$ ./scripts/get_maintainer.pl --git-blame --nogit --rolestats -f lib/bitmap.c
Paul Jackson <pj@sgi.com> (authored lines:406/613=66%,commits:7/20=35%)
Akinobu Mita <mita@miraclelinux.com> (authored lines:87/613=14%,commits:3/20=15%)
Reinette Chatre <reinette.chatre@linux.intel.com> (authored lines:42/613=7%)
Andrew Morton <akpm@linux-foundation.org> (commits:16/20=80%)
Paul Mundt <lethal@linux-sh.org> (commits:3/20=15%)
Randy Dunlap <randy.dunlap@oracle.com> (commits:2/20=10%)
$ ./scripts/get_maintainer.pl --git-blame --git --rolestats -f lib/bitmap.c
Andrew Morton <akpm@linux-foundation.org> (commit_signer:4/5=80%,commits:16/20=80%)
Akinobu Mita <akinobu.mita@gmail.com> (commit_signer:2/5=40%,authored lines:87/613=14%,commits:3/20=15%)
Jack Steiner <steiner@sgi.com> (commit_signer:1/5=20%)
Ben Hutchings <ben@decadent.org.uk> (commit_signer:1/5=20%)
Lee Schermerhorn <lee.schermerhorn@hp.com> (commit_signer:1/5=20%)
Paul Jackson <pj@sgi.com> (authored lines:406/613=66%,commits:7/20=35%)
Reinette Chatre <reinette.chatre@linux.intel.com> (authored lines:42/613=7%)
Paul Mundt <lethal@linux-sh.org> (commits:3/20=15%)
Randy Dunlap <randy.dunlap@oracle.com> (commits:2/20=10%)
linux-kernel@vger.kernel.org (open list)
Signed-off-by: Joe Perches <joe@perches.com>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
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); |