mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Andrew Morton <akpm@linuxfoundation.org>,
	Don Zickus <dzickus@redhat.com>,
	LKML <linux-kernel@vger.kernel.org>
Cc: Prarit Bhargava <prarit@redhat.com>, jtoppins@redhat.com
Subject: [PATCH] get_maintainer.pl: Add -mpath=<path or file> for MAINTAINERS file location
Date: Fri, 03 Aug 2018 18:11:53 -0700	[thread overview]
Message-ID: <a86e69195076ed3c4c526fddc76b86c28e0a1e37.camel@perches.com> (raw)
In-Reply-To: <20180706175419.6irtvs64e6dbz7hk@redhat.com>

Add the ability to have an override for the location of the
MAINTAINERS file.

Miscellanea:

o Properly indent a few lines with leading spaces

Suggested-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Joe Perches <joe@perches.com>
---
 scripts/get_maintainer.pl | 48 +++++++++++++++++++++++++++++------------------
 1 file changed, 30 insertions(+), 18 deletions(-)

diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index 82a482f858ee..0ebdefe74d5b 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -62,7 +62,7 @@ my $self_test = undef;
 my $version = 0;
 my $help = 0;
 my $find_maintainer_files = 0;
-
+my $maintainer_path;
 my $vcs_used = 0;
 
 my $exit = 0;
@@ -265,6 +265,7 @@ if (!GetOptions(
 		'fe|file-emails!' => \$file_emails,
 		'f|file' => \$from_filename,
 		'find-maintainer-files' => \$find_maintainer_files,
+		'mpath|maintainer-path=s' => \$maintainer_path,
 		'self-test:s' => \$self_test,
 		'v|version' => \$version,
 		'h|help|usage' => \$help,
@@ -386,26 +387,37 @@ sub find_ignore_git {
 read_all_maintainer_files();
 
 sub read_all_maintainer_files {
-    if (-d "${lk_path}MAINTAINERS") {
-        opendir(DIR, "${lk_path}MAINTAINERS") or die $!;
-        my @files = readdir(DIR);
-        closedir(DIR);
-        foreach my $file (@files) {
-            push(@mfiles, "${lk_path}MAINTAINERS/$file") if ($file !~ /^\./);
-        }
-    }
-
-    if ($find_maintainer_files) {
-        find( { wanted => \&find_is_maintainer_file,
-                preprocess => \&find_ignore_git,
-                no_chdir => 1,
-        }, "${lk_path}");
+    my $path = "${lk_path}MAINTAINERS";
+    if (defined $maintainer_path) {
+	$path = $maintainer_path;
+	# Perl Cookbook tilde expansion if necessary
+	$path =~ s@^~([^/]*)@ $1 ? (getpwnam($1))[7] : ( $ENV{HOME} || $ENV{LOGDIR} || (getpwuid($<))[7])@ex;
+    }
+
+    if (-d $path) {
+	$path .= '/' if ($path !~ m@/$@);
+	if ($path eq "${lk_path}MAINTAINERS/") {
+	    opendir(DIR, "$path") or die $!;
+	    my @files = readdir(DIR);
+	    closedir(DIR);
+	    foreach my $file (@files) {
+		push(@mfiles, "$path$file") if ($file !~ /^\./);
+	    }
+	}
+	if ($find_maintainer_files) {
+	    find( { wanted => \&find_is_maintainer_file,
+		    preprocess => \&find_ignore_git,
+		    no_chdir => 1,
+		}, "$path");
+	}
+    } elsif (-f "$path") {
+	push(@mfiles, "$path");
     } else {
-        push(@mfiles, "${lk_path}MAINTAINERS") if -f "${lk_path}MAINTAINERS";
+	die "$P: MAINTAINER file not found '$path'\n";
     }
-
+    die "$P: No MAINTAINER files found in '$path'\n" if (scalar(@mfiles) == 0);
     foreach my $file (@mfiles) {
-        read_maintainer_file("$file");
+	read_maintainer_file("$file");
     }
 }
 

      parent reply	other threads:[~2018-08-04  1:11 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-26 18:25 [PATCH] get_maintainer.pl: Add optional .get_maintainer.MAINTAINERS override Prarit Bhargava
2018-06-26 20:16 ` Joe Perches
2018-06-26 22:52   ` Prarit Bhargava
2018-06-26 23:04     ` Joe Perches
2018-06-26 23:29       ` Prarit Bhargava
2018-07-06 17:54   ` Don Zickus
2018-07-06 18:31     ` Joe Perches
2018-07-06 18:44       ` Don Zickus
2018-07-06 19:39         ` Prarit Bhargava
2018-07-06 21:36           ` Joe Perches
2018-07-06 21:58             ` Don Zickus
2018-07-06 22:09               ` Joe Perches
2018-07-06 22:12                 ` Don Zickus
2018-07-06 22:14                 ` Joe Perches
2018-07-06 22:30                   ` Don Zickus
2018-07-06 22:32                   ` Don Zickus
2018-07-13 18:51                   ` Don Zickus
2018-07-14  0:11                     ` Joe Perches
2018-07-16 21:20                       ` Don Zickus
2018-07-30 18:48                         ` Don Zickus
2018-07-06 19:47       ` Don Zickus
2018-08-04  1:11     ` Joe Perches [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a86e69195076ed3c4c526fddc76b86c28e0a1e37.camel@perches.com \
    --to=joe@perches.com \
    --cc=akpm@linuxfoundation.org \
    --cc=dzickus@redhat.com \
    --cc=jtoppins@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=prarit@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®