]> git.proxmox.com Git - mirror_qemu.git/blobdiff - scripts/get_maintainer.pl
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging
[mirror_qemu.git] / scripts / get_maintainer.pl
index 8261bcb1adc0e6d2a53c5965c5d2bd03dc639831..71415e3c706106958eb0a85cb98e921ba73077a9 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 # (c) 2007, Joe Perches <joe@perches.com>
 #           created from checkpatch.pl
 #
@@ -11,6 +11,7 @@
 # Licensed under the terms of the GNU GPL License version 2
 
 use strict;
+use warnings;
 
 my $P = $0;
 my $V = '0.26';
@@ -21,6 +22,7 @@ my $lk_path = "./";
 my $email = 1;
 my $email_usename = 1;
 my $email_maintainer = 1;
+my $email_reviewer = 1;
 my $email_list = 1;
 my $email_subscriber_list = 0;
 my $email_git = 0;
@@ -180,6 +182,7 @@ if (!GetOptions(
                'remove-duplicates!' => \$email_remove_duplicates,
                'mailmap!' => \$email_use_mailmap,
                'm!' => \$email_maintainer,
+               'r!' => \$email_reviewer,
                'n!' => \$email_usename,
                'l!' => \$email_list,
                's!' => \$email_subscriber_list,
@@ -238,7 +241,8 @@ if ($sections) {
 }
 
 if ($email &&
-    ($email_maintainer + $email_list + $email_subscriber_list +
+    ($email_maintainer + $email_reviewer +
+     $email_list + $email_subscriber_list +
      $email_git + $email_git_blame) == 0) {
     die "$P: Please select at least 1 email option\n";
 }
@@ -377,8 +381,8 @@ foreach my $file (@ARGV) {
        ##if $file is a directory and it lacks a trailing slash, add one
        if ((-d $file)) {
            $file =~ s@([^/])$@$1/@;
-       } elsif (!(-f $file)) {
-           die "$P: file '${file}' not found\n";
+       } elsif (!(stat $file)) {
+           die "$P: file '${file}' not found: $!\n";
        }
     }
     if ($from_filename) {
@@ -718,6 +722,7 @@ MAINTAINER field selection options:
     --hg-since => hg history to use (default: $email_hg_since)
     --interactive => display a menu (mostly useful if used with the --git option)
     --m => include maintainer(s) if any
+    --r => include reviewer(s) if any
     --n => include name 'Full Name <addr\@domain.tld>'
     --l => include list(s) if any
     --s => include subscriber only list(s) if any
@@ -744,7 +749,7 @@ Other options:
   --help => show this help information
 
 Default options:
-  [--email --nogit --git-fallback --m --n --l --multiline -pattern-depth=0
+  [--email --nogit --git-fallback --m --r --n --l --multiline --pattern-depth=0
    --remove-duplicates --rolestats]
 
 Notes:
@@ -892,20 +897,29 @@ sub find_ending_index {
     return $index;
 }
 
-sub get_maintainer_role {
+sub get_subsystem_name {
     my ($index) = @_;
 
-    my $i;
     my $start = find_starting_index($index);
-    my $end = find_ending_index($index);
 
-    my $role = "unknown";
     my $subsystem = $typevalue[$start];
     if (length($subsystem) > 20) {
        $subsystem = substr($subsystem, 0, 17);
        $subsystem =~ s/\s*$//;
        $subsystem = $subsystem . "...";
     }
+    return $subsystem;
+}
+
+sub get_maintainer_role {
+    my ($index) = @_;
+
+    my $i;
+    my $start = find_starting_index($index);
+    my $end = find_ending_index($index);
+
+    my $role = "unknown";
+    my $subsystem = get_subsystem_name($index);
 
     for ($i = $start + 1; $i < $end; $i++) {
        my $tv = $typevalue[$i];
@@ -939,16 +953,7 @@ sub get_maintainer_role {
 sub get_list_role {
     my ($index) = @_;
 
-    my $i;
-    my $start = find_starting_index($index);
-    my $end = find_ending_index($index);
-
-    my $subsystem = $typevalue[$start];
-    if (length($subsystem) > 20) {
-       $subsystem = substr($subsystem, 0, 17);
-       $subsystem =~ s/\s*$//;
-       $subsystem = $subsystem . "...";
-    }
+    my $subsystem = get_subsystem_name($index);
 
     if ($subsystem eq "THE REST") {
        $subsystem = "";
@@ -1022,6 +1027,23 @@ sub add_categories {
                    my $role = get_maintainer_role($i);
                    push_email_addresses($pvalue, $role);
                }
+           } elsif ($ptype eq "R") {
+               my ($name, $address) = parse_email($pvalue);
+               if ($name eq "") {
+                   if ($i > 0) {
+                       my $tv = $typevalue[$i - 1];
+                       if ($tv =~ m/^(.):\s*(.*)/) {
+                           if ($1 eq "P") {
+                               $name = $2;
+                               $pvalue = format_email($name, $address, $email_usename);
+                           }
+                       }
+                   }
+               }
+               if ($email_reviewer) {
+                   my $subsystem = get_subsystem_name($i);
+                   push_email_addresses($pvalue, "reviewer:$subsystem");
+               }
            } elsif ($ptype eq "T") {
                push(@scm, $pvalue);
            } elsif ($ptype eq "W") {
@@ -1354,7 +1376,7 @@ sub vcs_exists {
        warn("$P: No supported VCS found.  Add --nogit to options?\n");
        warn("Using a git repository produces better results.\n");
        warn("Try latest git repository using:\n");
-       warn("git clone git://git.qemu-project.org/qemu.git\n");
+       warn("git clone https://git.qemu.org/git/qemu.git\n");
        $printed_novcs = 1;
     }
     return 0;