]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - scripts/get_maintainer.pl
scripts/get_maintainer.pl: use .get_maintainer.conf from . then $HOME then scripts
[mirror_ubuntu-zesty-kernel.git] / scripts / get_maintainer.pl
index 65c6acf1bb3b6ca5f199e0047ee41ec9bd480cde..e5a400c53bf01bd50b77d20f8d6e46aa864be2d0 100755 (executable)
@@ -24,9 +24,10 @@ my $email_maintainer = 1;
 my $email_list = 1;
 my $email_subscriber_list = 0;
 my $email_git_penguin_chiefs = 0;
-my $email_git = 1;
+my $email_git = 0;
 my $email_git_all_signature_types = 0;
 my $email_git_blame = 0;
+my $email_git_fallback = 1;
 my $email_git_min_signatures = 1;
 my $email_git_max_maintainers = 5;
 my $email_git_min_percent = 5;
@@ -109,10 +110,12 @@ my %VCS_cmds_hg = (
     "blame_commit_pattern" => "^([0-9a-f]+):"
 );
 
-if (-f "${lk_path}.get_maintainer.conf") {
+my $conf = which_conf(".get_maintainer.conf");
+if (-f $conf) {
     my @conf_args;
-    open(my $conffile, '<', "${lk_path}.get_maintainer.conf")
-       or warn "$P: Can't open .get_maintainer.conf: $!\n";
+    open(my $conffile, '<', "$conf")
+       or warn "$P: Can't find a readable .get_maintainer.conf file $!\n";
+
     while (<$conffile>) {
        my $line = $_;
 
@@ -138,6 +141,7 @@ if (!GetOptions(
                'git!' => \$email_git,
                'git-all-signature-types!' => \$email_git_all_signature_types,
                'git-blame!' => \$email_git_blame,
+               'git-fallback!' => \$email_git_fallback,
                'git-chief-penguins!' => \$email_git_penguin_chiefs,
                'git-min-signatures=i' => \$email_git_min_signatures,
                'git-max-maintainers=i' => \$email_git_max_maintainers,
@@ -304,7 +308,7 @@ foreach my $file (@ARGV) {
     }
     if ($from_filename) {
        push(@files, $file);
-       if (-f $file && ($keywords || $file_emails)) {
+       if ($file ne "MAINTAINERS" && -f $file && ($keywords || $file_emails)) {
            open(my $f, '<', $file)
                or die "$P: Can't open $file: $!\n";
            my $text = do { local($/) ; <$f> };
@@ -371,6 +375,7 @@ my @status = ();
 foreach my $file (@files) {
 
     my %hash;
+    my $exact_pattern_match = 0;
     my $tvi = find_first_section();
     while ($tvi < @typevalue) {
        my $start = find_starting_index($tvi);
@@ -405,6 +410,8 @@ foreach my $file (@files) {
                            my $value_pd = ($value =~ tr@/@@);
                            my $file_pd = ($file  =~ tr@/@@);
                            $value_pd++ if (substr($value,-1,1) ne "/");
+                           $value_pd = -1 if ($value =~ /^\.\*/);
+                           $exact_pattern_match = 1 if ($value_pd >= $file_pd);
                            if ($pattern_depth == 0 ||
                                (($file_pd - $value_pd) < $pattern_depth)) {
                                $hash{$tvi} = $value_pd;
@@ -439,7 +446,8 @@ foreach my $file (@files) {
        }
     }
 
-    if ($email && $email_git) {
+    if ($email &&
+       ($email_git || ($email_git_fallback && !$exact_pattern_match))) {
        vcs_file_signoffs($file);
     }
 
@@ -540,6 +548,7 @@ MAINTAINER field selection options:
     --git => include recent git \*-by: signers
     --git-all-signature-types => include signers regardless of signature type
         or use only ${signaturePattern} signers (default: $email_git_all_signature_types)
+    --git-fallback => use git when no exact MAINTAINERS pattern (default: $email_git_fallback)
     --git-chief-penguins => include ${penguin_chiefs}
     --git-min-signatures => number of signatures required (default: $email_git_min_signatures)
     --git-max-maintainers => maximum maintainers to add (default: $email_git_max_maintainers)
@@ -954,6 +963,18 @@ sub which {
     return "";
 }
 
+sub which_conf {
+    my ($conf) = @_;
+
+    foreach my $path (split(/:/, ".:$ENV{HOME}:.scripts")) {
+       if (-e "$path/$conf") {
+           return "$path/$conf";
+       }
+    }
+
+    return "";
+}
+
 sub mailmap {
     my (@lines) = @_;
     my %hash;