From 43e33fd45ff549c90fe35049b351eada58ea19cf Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Mon, 26 Oct 2009 16:49:47 -0700 Subject: [PATCH] --- yaml --- r: 167739 b: refs/heads/master c: dcf36a92f569b2c240129d8c6ae4c366c1658766 h: refs/heads/master i: 167737: c917f15bfe35d8e48117aca513a5c32b7184a22b 167735: ec30161956b22fde9e6701db486ceb4929c20b71 v: v3 --- [refs] | 2 +- trunk/scripts/get_maintainer.pl | 37 +++++++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/[refs] b/[refs] index 7e96b96815d8..43e71614901b 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 27480ccc29c84206ad53f1990d4a22ff6236de91 +refs/heads/master: dcf36a92f569b2c240129d8c6ae4c366c1658766 diff --git a/trunk/scripts/get_maintainer.pl b/trunk/scripts/get_maintainer.pl index cdb44b63342e..102b76608f35 100755 --- a/trunk/scripts/get_maintainer.pl +++ b/trunk/scripts/get_maintainer.pl @@ -13,7 +13,7 @@ use strict; my $P = $0; -my $V = '0.20'; +my $V = '0.21'; use Getopt::Long qw(:config no_auto_abbrev); @@ -37,6 +37,7 @@ my $web = 0; my $subsystem = 0; my $status = 0; +my $keywords = 1; my $from_filename = 0; my $pattern_depth = 0; my $version = 0; @@ -84,6 +85,7 @@ 'scm!' => \$scm, 'web!' => \$web, 'pattern-depth=i' => \$pattern_depth, + 'k|keywords!' => \$keywords, 'f|file' => \$from_filename, 'v|version' => \$version, 'h|help' => \$help, @@ -132,6 +134,8 @@ ## Read MAINTAINERS for type/value pairs my @typevalue = (); +my %keyword_hash; + open(MAINT, "<${lk_path}MAINTAINERS") || die "$P: Can't open MAINTAINERS\n"; while () { my $line = $_; @@ -149,6 +153,8 @@ if ((-d $value)) { $value =~ s@([^/])$@$1/@; } + } elsif ($type eq "K") { + $keyword_hash{@typevalue} = $value; } push(@typevalue, "$type:$value"); } elsif (!/^(\s)*$/) { @@ -188,6 +194,7 @@ my @files = (); my @range = (); +my @keyword_tvi = (); foreach my $file (@ARGV) { ##if $file is a directory and it lacks a trailing slash, add one @@ -198,11 +205,24 @@ } if ($from_filename) { push(@files, $file); + if (-f $file && $keywords) { + open(FILE, "<$file") or die "$P: Can't open ${file}\n"; + while () { + my $patch_line = $_; + foreach my $line (keys %keyword_hash) { + if ($patch_line =~ m/^.*$keyword_hash{$line}/x) { + push(@keyword_tvi, $line); + } + } + } + close(FILE); + } } else { my $file_cnt = @files; my $lastfile; open(PATCH, "<$file") or die "$P: Can't open ${file}\n"; while () { + my $patch_line = $_; if (m/^\+\+\+\s+(\S+)/) { my $filename = $1; $filename =~ s@^[^/]*/@@; @@ -213,6 +233,12 @@ if ($email_git_blame) { push(@range, "$lastfile:$1:$2"); } + } elsif ($keywords) { + foreach my $line (keys %keyword_hash) { + if ($patch_line =~ m/^[+-].*$keyword_hash{$line}/x) { + push(@keyword_tvi, $line); + } + } } } close(PATCH); @@ -286,6 +312,13 @@ } } +if ($keywords) { + @keyword_tvi = sort_and_uniq(@keyword_tvi); + foreach my $line (@keyword_tvi) { + add_categories($line); + } +} + if ($email) { foreach my $chief (@penguin_chief) { if ($chief =~ m/^(.*):(.*)/) { @@ -384,6 +417,7 @@ sub usage { Other options: --pattern-depth => Number of pattern directory traversals (default: 0 (all)) + --keywords => scan patch for keywords (default: 1 (on)) --version => show version --help => show this help information @@ -486,7 +520,6 @@ sub format_email { } sub find_starting_index { - my ($index) = @_; while ($index > 0) {