diff options
author | Joe Perches <joe@perches.com> | 2009-10-26 19:49:47 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-10-29 10:39:26 -0400 |
commit | dcf36a92f569b2c240129d8c6ae4c366c1658766 (patch) | |
tree | 259148e3a6dd95ea73509494c8dac9f5d9fe713b /scripts | |
parent | 27480ccc29c84206ad53f1990d4a22ff6236de91 (diff) |
scripts/get_maintainer.pl: add patch/file search for keywords
Based on an idea from Wolfram Sang.
Add search for MAINTAINERS line "K:" regex pattern match in a patch or file
Matches are added after file pattern matches
Add --keywords command line switch (default 1, on)
Change version to 0.21
Signed-off-by: Joe Perches <joe@perches.com>
Cc: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/get_maintainer.pl | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl index cdb44b63342e..102b76608f35 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.20'; | 16 | my $V = '0.21'; |
17 | 17 | ||
18 | use Getopt::Long qw(:config no_auto_abbrev); | 18 | use Getopt::Long qw(:config no_auto_abbrev); |
19 | 19 | ||
@@ -37,6 +37,7 @@ my $scm = 0; | |||
37 | my $web = 0; | 37 | my $web = 0; |
38 | my $subsystem = 0; | 38 | my $subsystem = 0; |
39 | my $status = 0; | 39 | my $status = 0; |
40 | my $keywords = 1; | ||
40 | my $from_filename = 0; | 41 | my $from_filename = 0; |
41 | my $pattern_depth = 0; | 42 | my $pattern_depth = 0; |
42 | my $version = 0; | 43 | my $version = 0; |
@@ -84,6 +85,7 @@ if (!GetOptions( | |||
84 | 'scm!' => \$scm, | 85 | 'scm!' => \$scm, |
85 | 'web!' => \$web, | 86 | 'web!' => \$web, |
86 | 'pattern-depth=i' => \$pattern_depth, | 87 | 'pattern-depth=i' => \$pattern_depth, |
88 | 'k|keywords!' => \$keywords, | ||
87 | 'f|file' => \$from_filename, | 89 | 'f|file' => \$from_filename, |
88 | 'v|version' => \$version, | 90 | 'v|version' => \$version, |
89 | 'h|help' => \$help, | 91 | 'h|help' => \$help, |
@@ -132,6 +134,8 @@ if (!top_of_kernel_tree($lk_path)) { | |||
132 | ## Read MAINTAINERS for type/value pairs | 134 | ## Read MAINTAINERS for type/value pairs |
133 | 135 | ||
134 | my @typevalue = (); | 136 | my @typevalue = (); |
137 | my %keyword_hash; | ||
138 | |||
135 | open(MAINT, "<${lk_path}MAINTAINERS") || die "$P: Can't open MAINTAINERS\n"; | 139 | open(MAINT, "<${lk_path}MAINTAINERS") || die "$P: Can't open MAINTAINERS\n"; |
136 | while (<MAINT>) { | 140 | while (<MAINT>) { |
137 | my $line = $_; | 141 | my $line = $_; |
@@ -149,6 +153,8 @@ while (<MAINT>) { | |||
149 | if ((-d $value)) { | 153 | if ((-d $value)) { |
150 | $value =~ s@([^/])$@$1/@; | 154 | $value =~ s@([^/])$@$1/@; |
151 | } | 155 | } |
156 | } elsif ($type eq "K") { | ||
157 | $keyword_hash{@typevalue} = $value; | ||
152 | } | 158 | } |
153 | push(@typevalue, "$type:$value"); | 159 | push(@typevalue, "$type:$value"); |
154 | } elsif (!/^(\s)*$/) { | 160 | } elsif (!/^(\s)*$/) { |
@@ -188,6 +194,7 @@ if ($email_remove_duplicates) { | |||
188 | 194 | ||
189 | my @files = (); | 195 | my @files = (); |
190 | my @range = (); | 196 | my @range = (); |
197 | my @keyword_tvi = (); | ||
191 | 198 | ||
192 | foreach my $file (@ARGV) { | 199 | foreach my $file (@ARGV) { |
193 | ##if $file is a directory and it lacks a trailing slash, add one | 200 | ##if $file is a directory and it lacks a trailing slash, add one |
@@ -198,11 +205,24 @@ foreach my $file (@ARGV) { | |||
198 | } | 205 | } |
199 | if ($from_filename) { | 206 | if ($from_filename) { |
200 | push(@files, $file); | 207 | push(@files, $file); |
208 | if (-f $file && $keywords) { | ||
209 | open(FILE, "<$file") or die "$P: Can't open ${file}\n"; | ||
210 | while (<FILE>) { | ||
211 | my $patch_line = $_; | ||
212 | foreach my $line (keys %keyword_hash) { | ||
213 | if ($patch_line =~ m/^.*$keyword_hash{$line}/x) { | ||
214 | push(@keyword_tvi, $line); | ||
215 | } | ||
216 | } | ||
217 | } | ||
218 | close(FILE); | ||
219 | } | ||
201 | } else { | 220 | } else { |
202 | my $file_cnt = @files; | 221 | my $file_cnt = @files; |
203 | my $lastfile; | 222 | my $lastfile; |
204 | open(PATCH, "<$file") or die "$P: Can't open ${file}\n"; | 223 | open(PATCH, "<$file") or die "$P: Can't open ${file}\n"; |
205 | while (<PATCH>) { | 224 | while (<PATCH>) { |
225 | my $patch_line = $_; | ||
206 | if (m/^\+\+\+\s+(\S+)/) { | 226 | if (m/^\+\+\+\s+(\S+)/) { |
207 | my $filename = $1; | 227 | my $filename = $1; |
208 | $filename =~ s@^[^/]*/@@; | 228 | $filename =~ s@^[^/]*/@@; |
@@ -213,6 +233,12 @@ foreach my $file (@ARGV) { | |||
213 | if ($email_git_blame) { | 233 | if ($email_git_blame) { |
214 | push(@range, "$lastfile:$1:$2"); | 234 | push(@range, "$lastfile:$1:$2"); |
215 | } | 235 | } |
236 | } elsif ($keywords) { | ||
237 | foreach my $line (keys %keyword_hash) { | ||
238 | if ($patch_line =~ m/^[+-].*$keyword_hash{$line}/x) { | ||
239 | push(@keyword_tvi, $line); | ||
240 | } | ||
241 | } | ||
216 | } | 242 | } |
217 | } | 243 | } |
218 | close(PATCH); | 244 | close(PATCH); |
@@ -286,6 +312,13 @@ foreach my $file (@files) { | |||
286 | } | 312 | } |
287 | } | 313 | } |
288 | 314 | ||
315 | if ($keywords) { | ||
316 | @keyword_tvi = sort_and_uniq(@keyword_tvi); | ||
317 | foreach my $line (@keyword_tvi) { | ||
318 | add_categories($line); | ||
319 | } | ||
320 | } | ||
321 | |||
289 | if ($email) { | 322 | if ($email) { |
290 | foreach my $chief (@penguin_chief) { | 323 | foreach my $chief (@penguin_chief) { |
291 | if ($chief =~ m/^(.*):(.*)/) { | 324 | if ($chief =~ m/^(.*):(.*)/) { |
@@ -384,6 +417,7 @@ Output type options: | |||
384 | 417 | ||
385 | Other options: | 418 | Other options: |
386 | --pattern-depth => Number of pattern directory traversals (default: 0 (all)) | 419 | --pattern-depth => Number of pattern directory traversals (default: 0 (all)) |
420 | --keywords => scan patch for keywords (default: 1 (on)) | ||
387 | --version => show version | 421 | --version => show version |
388 | --help => show this help information | 422 | --help => show this help information |
389 | 423 | ||
@@ -486,7 +520,6 @@ sub format_email { | |||
486 | } | 520 | } |
487 | 521 | ||
488 | sub find_starting_index { | 522 | sub find_starting_index { |
489 | |||
490 | my ($index) = @_; | 523 | my ($index) = @_; |
491 | 524 | ||
492 | while ($index > 0) { | 525 | while ($index > 0) { |