Skip to content

Commit 5f0baf9

Browse files
JoePerchestorvalds
authored andcommitted
get_maintainer.pl: add -mpath=<path or file> for MAINTAINERS file location
Add the ability to have an override for the location of the MAINTAINERS file. Miscellanea: o Properly indent a few lines with leading spaces Link: http://lkml.kernel.org/r/a86e69195076ed3c4c526fddc76b86c28e0a1e37.camel@perches.com Signed-off-by: Joe Perches <joe@perches.com> Suggested-by: Don Zickus <dzickus@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 31bb82c commit 5f0baf9

1 file changed

Lines changed: 30 additions & 18 deletions

File tree

‎scripts/get_maintainer.pl‎

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
my $version = 0;
6363
my $help = 0;
6464
my $find_maintainer_files = 0;
65-
65+
my $maintainer_path;
6666
my $vcs_used = 0;
6767

6868
my $exit = 0;
@@ -265,6 +265,7 @@
265265
'fe|file-emails!' => \$file_emails,
266266
'f|file' => \$from_filename,
267267
'find-maintainer-files' => \$find_maintainer_files,
268+
'mpath|maintainer-path=s' => \$maintainer_path,
268269
'self-test:s' => \$self_test,
269270
'v|version' => \$version,
270271
'h|help|usage' => \$help,
@@ -386,26 +387,37 @@ sub find_ignore_git {
386387
read_all_maintainer_files();
387388

388389
sub read_all_maintainer_files {
389-
if (-d "${lk_path}MAINTAINERS") {
390-
opendir(DIR, "${lk_path}MAINTAINERS") or die $!;
391-
my @files = readdir(DIR);
392-
closedir(DIR);
393-
foreach my $file (@files) {
394-
push(@mfiles, "${lk_path}MAINTAINERS/$file") if ($file !~ /^\./);
395-
}
396-
}
397-
398-
if ($find_maintainer_files) {
399-
find( { wanted => \&find_is_maintainer_file,
400-
preprocess => \&find_ignore_git,
401-
no_chdir => 1,
402-
}, "${lk_path}");
390+
my $path = "${lk_path}MAINTAINERS";
391+
if (defined $maintainer_path) {
392+
$path = $maintainer_path;
393+
# Perl Cookbook tilde expansion if necessary
394+
$path =~ s@^~([^/]*)@ $1 ? (getpwnam($1))[7] : ( $ENV{HOME} || $ENV{LOGDIR} || (getpwuid($<))[7])@ex;
395+
}
396+
397+
if (-d $path) {
398+
$path .= '/' if ($path !~ m@/$@);
399+
if ($path eq "${lk_path}MAINTAINERS/") {
400+
opendir(DIR, "$path") or die $!;
401+
my @files = readdir(DIR);
402+
closedir(DIR);
403+
foreach my $file (@files) {
404+
push(@mfiles, "$path$file") if ($file !~ /^\./);
405+
}
406+
}
407+
if ($find_maintainer_files) {
408+
find( { wanted => \&find_is_maintainer_file,
409+
preprocess => \&find_ignore_git,
410+
no_chdir => 1,
411+
}, "$path");
412+
}
413+
} elsif (-f "$path") {
414+
push(@mfiles, "$path");
403415
} else {
404-
push(@mfiles, "${lk_path}MAINTAINERS") if -f "${lk_path}MAINTAINERS";
416+
die "$P: MAINTAINER file not found '$path'\n";
405417
}
406-
418+
die "$P: No MAINTAINER files found in '$path'\n" if (scalar(@mfiles) == 0);
407419
foreach my $file (@mfiles) {
408-
read_maintainer_file("$file");
420+
read_maintainer_file("$file");
409421
}
410422
}
411423

0 commit comments

Comments
 (0)