]> git.proxmox.com Git - mirror_qemu.git/blobdiff - scripts/get_maintainer.pl
Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into staging
[mirror_qemu.git] / scripts / get_maintainer.pl
index d29a8d75cb22ebb37f747f1b0b46d5df24974e58..8261bcb1adc0e6d2a53c5965c5d2bd03dc639831 100755 (executable)
@@ -23,7 +23,6 @@ my $email_usename = 1;
 my $email_maintainer = 1;
 my $email_list = 1;
 my $email_subscriber_list = 0;
-my $email_git_penguin_chiefs = 0;
 my $email_git = 0;
 my $email_git_all_signature_types = 0;
 my $email_git_blame = 0;
@@ -60,21 +59,6 @@ my $exit = 0;
 my %commit_author_hash;
 my %commit_signer_hash;
 
-my @penguin_chief = ();
-push(@penguin_chief, "Linus Torvalds:torvalds\@linux-foundation.org");
-#Andrew wants in on most everything - 2009/01/14
-#push(@penguin_chief, "Andrew Morton:akpm\@linux-foundation.org");
-
-my @penguin_chief_names = ();
-foreach my $chief (@penguin_chief) {
-    if ($chief =~ m/^(.*):(.*)/) {
-       my $chief_name = $1;
-       my $chief_addr = $2;
-       push(@penguin_chief_names, $chief_name);
-    }
-}
-my $penguin_chiefs = "\(" . join("|", @penguin_chief_names) . "\)";
-
 # Signature types of people who are either
 #      a) responsible for the code in question, or
 #      b) familiar enough with it to give relevant feedback
@@ -83,6 +67,8 @@ push(@signature_tags, "Signed-off-by:");
 push(@signature_tags, "Reviewed-by:");
 push(@signature_tags, "Acked-by:");
 
+my $signature_pattern = "\(" . join("|", @signature_tags) . "\)";
+
 # rfc822 email address - preloaded methods go here.
 my $rfc822_lwsp = "(?:(?:\\r\\n)?[ \\t])";
 my $rfc822_char = '[\\000-\\377]';
@@ -95,7 +81,7 @@ my %VCS_cmds_git = (
     "execute_cmd" => \&git_execute_cmd,
     "available" => '(which("git") ne "") && (-d ".git")',
     "find_signers_cmd" =>
-       "git log --no-color --since=\$email_git_since " .
+       "git log --no-color --follow --since=\$email_git_since " .
            '--format="GitCommit: %H%n' .
                      'GitAuthor: %an <%ae>%n' .
                      'GitDate: %aD%n' .
@@ -185,7 +171,6 @@ if (!GetOptions(
                'git-blame!' => \$email_git_blame,
                'git-blame-signatures!' => \$email_git_blame_signatures,
                '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,
                'git-min-percent=i' => \$email_git_min_percent,
@@ -254,13 +239,13 @@ if ($sections) {
 
 if ($email &&
     ($email_maintainer + $email_list + $email_subscriber_list +
-     $email_git + $email_git_penguin_chiefs + $email_git_blame) == 0) {
+     $email_git + $email_git_blame) == 0) {
     die "$P: Please select at least 1 email option\n";
 }
 
-if (!top_of_kernel_tree($lk_path)) {
+if (!top_of_tree($lk_path)) {
     die "$P: The current directory does not appear to be "
-       . "a linux kernel source tree.\n";
+       . "a QEMU source tree.\n";
 }
 
 ## Read MAINTAINERS for type/value pairs
@@ -273,7 +258,7 @@ open (my $maint, '<', "${lk_path}MAINTAINERS")
 while (<$maint>) {
     my $line = $_;
 
-    if ($line =~ m/^(\C):\s*(.*)/) {
+    if ($line =~ m/^(.):\s*(.*)/) {
        my $type = $1;
        my $value = $2;
 
@@ -328,7 +313,8 @@ sub read_mailmap {
        # name1 <mail1> <mail2>
        # name1 <mail1> name2 <mail2>
        # (see man git-shortlog)
-       if (/^(.+)<(.+)>$/) {
+
+       if (/^([^<]+)<([^>]+)>$/) {
            my $real_name = $1;
            my $address = $2;
 
@@ -336,13 +322,13 @@ sub read_mailmap {
            ($real_name, $address) = parse_email("$real_name <$address>");
            $mailmap->{names}->{$address} = $real_name;
 
-       } elsif (/^<([^\s]+)>\s*<([^\s]+)>$/) {
+       } elsif (/^<([^>]+)>\s*<([^>]+)>$/) {
            my $real_address = $1;
            my $wrong_address = $2;
 
            $mailmap->{addresses}->{$wrong_address} = $real_address;
 
-       } elsif (/^(.+)<([^\s]+)>\s*<([^\s]+)>$/) {
+       } elsif (/^(.+)<([^>]+)>\s*<([^>]+)>$/) {
            my $real_name = $1;
            my $real_address = $2;
            my $wrong_address = $3;
@@ -353,7 +339,7 @@ sub read_mailmap {
            $mailmap->{names}->{$wrong_address} = $real_name;
            $mailmap->{addresses}->{$wrong_address} = $real_address;
 
-       } elsif (/^(.+)<([^\s]+)>\s*([^\s].*)<([^\s]+)>$/) {
+       } elsif (/^(.+)<([^>]+)>\s*(.+)\s*<([^>]+)>$/) {
            my $real_name = $1;
            my $real_address = $2;
            my $wrong_name = $3;
@@ -472,7 +458,6 @@ my @subsystem = ();
 my @status = ();
 my %deduplicate_name_hash = ();
 my %deduplicate_address_hash = ();
-my $signature_pattern;
 
 my @maintainers = get_maintainers();
 
@@ -508,7 +493,7 @@ sub range_is_maintained {
 
     for (my $i = $start; $i < $end; $i++) {
        my $line = $typevalue[$i];
-       if ($line =~ m/^(\C):\s*(.*)/) {
+       if ($line =~ m/^(.):\s*(.*)/) {
            my $type = $1;
            my $value = $2;
            if ($type eq 'S') {
@@ -526,7 +511,7 @@ sub range_has_maintainer {
 
     for (my $i = $start; $i < $end; $i++) {
        my $line = $typevalue[$i];
-       if ($line =~ m/^(\C):\s*(.*)/) {
+       if ($line =~ m/^(.):\s*(.*)/) {
            my $type = $1;
            my $value = $2;
            if ($type eq 'M') {
@@ -575,7 +560,7 @@ sub get_maintainers {
 
            for ($i = $start; $i < $end; $i++) {
                my $line = $typevalue[$i];
-               if ($line =~ m/^(\C):\s*(.*)/) {
+               if ($line =~ m/^(.):\s*(.*)/) {
                    my $type = $1;
                    my $value = $2;
                    if ($type eq 'X') {
@@ -590,7 +575,7 @@ sub get_maintainers {
            if (!$exclude) {
                for ($i = $start; $i < $end; $i++) {
                    my $line = $typevalue[$i];
-                   if ($line =~ m/^(\C):\s*(.*)/) {
+                   if ($line =~ m/^(.):\s*(.*)/) {
                        my $type = $1;
                        my $value = $2;
                        if ($type eq 'F') {
@@ -649,28 +634,23 @@ sub get_maintainers {
        $email->[0] = deduplicate_email($email->[0]);
     }
 
-    foreach my $file (@files) {
-       if ($email &&
-           ($email_git || ($email_git_fallback &&
-                           !$exact_pattern_match_hash{$file}))) {
-           vcs_file_signoffs($file);
-       }
-       if ($email && $email_git_blame) {
-           vcs_file_blame($file);
-       }
-    }
-
     if ($email) {
-       foreach my $chief (@penguin_chief) {
-           if ($chief =~ m/^(.*):(.*)/) {
-               my $email_address;
+       if (! $interactive) {
+           $email_git_fallback = 0 if @email_to > 0 || $email_git || $email_git_blame;
+           if ($email_git_fallback) {
+               print STDERR "get_maintainer.pl: No maintainers found, printing recent contributors.\n";
+               print STDERR "get_maintainer.pl: Do not blindly cc: them on patches!  Use common sense.\n";
+               print STDERR "\n";
+            }
+        }
 
-               $email_address = format_email($1, $2, $email_usename);
-               if ($email_git_penguin_chiefs) {
-                   push(@email_to, [$email_address, 'chief penguin']);
-               } else {
-                   @email_to = grep($_->[0] !~ /${email_address}/, @email_to);
-               }
+       foreach my $file (@files) {
+           if ($email_git || ($email_git_fallback &&
+                              !$exact_pattern_match_hash{$file})) {
+               vcs_file_signoffs($file);
+           }
+           if ($email_git_blame) {
+               vcs_file_blame($file);
            }
        }
 
@@ -730,7 +710,6 @@ MAINTAINER field selection options:
     --git-all-signature-types => include signers regardless of signature type
         or use only ${signature_pattern} 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)
     --git-min-percent => minimum percentage of commits required (default: $email_git_min_percent)
@@ -792,7 +771,7 @@ Notes:
           --git-min-signatures, --git-max-maintainers, --git-min-percent, and
           --git-blame
       Use --hg-since not --git-since to control date selection
-  File ".get_maintainer.conf", if it exists in the linux kernel source root
+  File ".get_maintainer.conf", if it exists in the QEMU source root
       directory, can change whatever get_maintainer defaults are desired.
       Entries in this file can be any command line argument.
       This file is prepended to any additional command line arguments.
@@ -800,28 +779,18 @@ Notes:
 EOT
 }
 
-sub top_of_kernel_tree {
+sub top_of_tree {
     my ($lk_path) = @_;
 
     if ($lk_path ne "" && substr($lk_path,length($lk_path)-1,1) ne "/") {
        $lk_path .= "/";
     }
-    if (   (-f "${lk_path}COPYING")
-       && (-f "${lk_path}CREDITS")
-       && (-f "${lk_path}Kbuild")
-       && (-f "${lk_path}MAINTAINERS")
-       && (-f "${lk_path}Makefile")
-       && (-f "${lk_path}README")
-       && (-d "${lk_path}Documentation")
-       && (-d "${lk_path}arch")
-       && (-d "${lk_path}include")
-       && (-d "${lk_path}drivers")
-       && (-d "${lk_path}fs")
-       && (-d "${lk_path}init")
-       && (-d "${lk_path}ipc")
-       && (-d "${lk_path}kernel")
-       && (-d "${lk_path}lib")
-       && (-d "${lk_path}scripts")) {
+    if (    (-f "${lk_path}COPYING")
+        && (-f "${lk_path}MAINTAINERS")
+        && (-f "${lk_path}Makefile")
+        && (-d "${lk_path}docs")
+        && (-f "${lk_path}VERSION")
+        && (-f "${lk_path}vl.c")) {
        return 1;
     }
     return 0;
@@ -886,7 +855,7 @@ sub find_first_section {
 
     while ($index < @typevalue) {
        my $tv = $typevalue[$index];
-       if (($tv =~ m/^(\C):\s*(.*)/)) {
+       if (($tv =~ m/^(.):\s*(.*)/)) {
            last;
        }
        $index++;
@@ -900,7 +869,7 @@ sub find_starting_index {
 
     while ($index > 0) {
        my $tv = $typevalue[$index];
-       if (!($tv =~ m/^(\C):\s*(.*)/)) {
+       if (!($tv =~ m/^(.):\s*(.*)/)) {
            last;
        }
        $index--;
@@ -914,7 +883,7 @@ sub find_ending_index {
 
     while ($index < @typevalue) {
        my $tv = $typevalue[$index];
-       if (!($tv =~ m/^(\C):\s*(.*)/)) {
+       if (!($tv =~ m/^(.):\s*(.*)/)) {
            last;
        }
        $index++;
@@ -930,7 +899,7 @@ sub get_maintainer_role {
     my $start = find_starting_index($index);
     my $end = find_ending_index($index);
 
-    my $role;
+    my $role = "unknown";
     my $subsystem = $typevalue[$start];
     if (length($subsystem) > 20) {
        $subsystem = substr($subsystem, 0, 17);
@@ -940,7 +909,7 @@ sub get_maintainer_role {
 
     for ($i = $start + 1; $i < $end; $i++) {
        my $tv = $typevalue[$i];
-       if ($tv =~ m/^(\C):\s*(.*)/) {
+       if ($tv =~ m/^(.):\s*(.*)/) {
            my $ptype = $1;
            my $pvalue = $2;
            if ($ptype eq "S") {
@@ -999,7 +968,7 @@ sub add_categories {
 
     for ($i = $start + 1; $i < $end; $i++) {
        my $tv = $typevalue[$i];
-       if ($tv =~ m/^(\C):\s*(.*)/) {
+       if ($tv =~ m/^(.):\s*(.*)/) {
            my $ptype = $1;
            my $pvalue = $2;
            if ($ptype eq "L") {
@@ -1026,8 +995,13 @@ sub add_categories {
                    if ($email_list) {
                        if (!$hash_list_to{lc($list_address)}) {
                            $hash_list_to{lc($list_address)} = 1;
-                           push(@list_to, [$list_address,
-                                           "open list${list_role}"]);
+                           if ($list_additional =~ m/moderated/) {
+                               push(@list_to, [$list_address,
+                                               "moderated list${list_role}"]);
+                           } else {
+                               push(@list_to, [$list_address,
+                                               "open list${list_role}"]);
+                           }
                        }
                    }
                }
@@ -1036,7 +1010,7 @@ sub add_categories {
                if ($name eq "") {
                    if ($i > 0) {
                        my $tv = $typevalue[$i - 1];
-                       if ($tv =~ m/^(\C):\s*(.*)/) {
+                       if ($tv =~ m/^(.):\s*(.*)/) {
                            if ($1 eq "P") {
                                $name = $2;
                                $pvalue = format_email($name, $address, $email_usename);
@@ -1276,10 +1250,6 @@ sub vcs_find_signers {
     save_commits_by_author(@lines) if ($interactive);
     save_commits_by_signer(@lines) if ($interactive);
 
-    if (!$email_git_penguin_chiefs) {
-       @signatures = grep(!/${penguin_chiefs}/i, @signatures);
-    }
-
     my ($types_ref, $signers_ref) = extract_formatted_signatures(@signatures);
 
     return ($commits, @$signers_ref);
@@ -1291,10 +1261,6 @@ sub vcs_find_author {
 
     @lines = &{$VCS_cmds{"execute_cmd"}}($cmd);
 
-    if (!$email_git_penguin_chiefs) {
-       @lines = grep(!/${penguin_chiefs}/i, @lines);
-    }
-
     return @lines if !@lines;
 
     my @authors = ();
@@ -1387,8 +1353,8 @@ sub vcs_exists {
     if (!$printed_novcs) {
        warn("$P: No supported VCS found.  Add --nogit to options?\n");
        warn("Using a git repository produces better results.\n");
-       warn("Try Linus Torvalds' latest git repository using:\n");
-       warn("git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git\n");
+       warn("Try latest git repository using:\n");
+       warn("git clone git://git.qemu-project.org/qemu.git\n");
        $printed_novcs = 1;
     }
     return 0;
@@ -1920,10 +1886,6 @@ sub vcs_file_blame {
 
                @lines = &{$VCS_cmds{"execute_cmd"}}($cmd);
 
-               if (!$email_git_penguin_chiefs) {
-                   @lines = grep(!/${penguin_chiefs}/i, @lines);
-               }
-
                last if !@lines;
 
                my @authors = ();