scripts/get_maintainer.pl: add role output option
PATCH 1/1 scripts/get_maintainer.pl: add role output option
Add the output option '--roles' to get_maintainer.pl. This causes it to show the role of each email address, i.e. why it was selected.
--- scripts/get_maintainer.pl | 52 ++++++++++++++++++++++++++++++++------------- 1 files changed, 37 insertions(+), 15 deletions(-)
scripts/get_maintainer.pl +37 -15
@@ -33,6 +33,7 @@ my $email_git_blame = 0; my $email_remove_duplicates = 1; my $output_multiline = 1; my $output_separator = ", "; +my $output_roles = 0; my $scm = 0; my $web = 0; my $subsystem = 0;
@@ -78,6 +79,7 @@ if (!GetOptions( 'l!' => \$email_list, 's!' => \$email_subscriber_list, 'multiline!' => \$output_multiline, + 'roles!' => \$output_roles, 'separator=s' => \$output_separator, 'subsystem!' => \$subsystem, 'status!' => \$status,
@@ -293,9 +295,9 @@ if ($email) { $email_address = format_email($1, $2); if ($email_git_penguin_chiefs) { - push(@email_to, $email_address); + push(@email_to, [$email_address, 'chief penguin']); } else { - @email_to = grep(!/${email_address}/, @email_to); + @email_to = grep($_->[0] !~ /${email_address}/, @email_to); } } }
@@ -309,7 +311,7 @@ if ($email || $email_list) { if ($email_list) { @to = (@to, @list_to); } - output(uniq(@to)); + output(merge_email(@to)); } if ($scm) {
@@ -381,6 +383,7 @@ Output type options: --separator [, ] => separator for multiple entries on 1 line using --separator also sets --nomultiline if --separator is not [, ] --multiline => print 1 entry per line + --roles => show roles Other options: --pattern-depth => Number of pattern directory traversals (default: 0 (all))
@@ -537,11 +540,11 @@ sub add_categories { } if ($list_additional =~ m/subscribers-only/) { if ($email_subscriber_list) { - push(@list_to, $list_address); + push(@list_to, [$list_address, 'subscriber list']); } } else { if ($email_list) { - push(@list_to, $list_address); + push(@list_to, [$list_address, 'open list']); } } } elsif ($ptype eq "M") {
@@ -558,7 +561,7 @@ sub add_categories { } } if ($email_maintainer) { - push_email_addresses($pvalue); + push_email_addresses($pvalue, 'maintainer'); } } elsif ($ptype eq "T") { push(@scm, $pvalue);
@@ -585,7 +588,7 @@ sub email_inuse { } sub push_email_address { - my ($line) = @_; + my ($line, $role) = @_; my ($name, $address) = parse_email($line);
@@ -594,9 +597,9 @@ sub push_email_address { } if (!$email_remove_duplicates) { - push(@email_to, format_email($name, $address)); + push(@email_to, [format_email($name, $address), $role]); } elsif (!email_inuse($name, $address)) { - push(@email_to, format_email($name, $address)); + push(@email_to, [format_email($name, $address), $role]); $email_hash_name{$name}++; $email_hash_address{$address}++; }
@@ -605,19 +608,19 @@ sub push_email_address { } sub push_email_addresses { - my ($address) = @_; + my ($address, $role) = @_; my @address_list = (); if (rfc822_valid($address)) { - push_email_address($address); + push_email_address($address, $role); } elsif (@address_list = rfc822_validlist($address)) { my $array_count = shift(@address_list); while (my $entry = shift(@address_list)) { - push_email_address($entry); + push_email_address($entry, $role); } } else { - if (!push_email_address($address)) { + if (!push_email_address($address, $role)) { warn("Invalid MAINTAINERS address: '" . $address . "'\n"); } }
@@ -714,7 +717,7 @@ sub recent_git_signoffs { last if ($sign_offs < $email_git_min_signatures || $count > $email_git_max_maintainers || $sign_offs * 100 / $total_sign_offs < $email_git_min_percent); - push_email_address($line); + push_email_address($line, 'signed-off'); } }
@@ -795,7 +798,7 @@ sub git_assign_blame { last if ($sign_offs < $email_git_min_signatures || $count > $email_git_max_maintainers || $sign_offs * 100 / $total_sign_offs < $email_git_min_percent); - push_email_address($line); + push_email_address($line, 'blamed'); } }
@@ -816,6 +819,25 @@ sub sort_and_uniq { return @parms; } +sub merge_email { + my @lines; + my %saw; + + for (@_) { + my ($address, $role) = @$_; + if (!$saw{$address}) { + if ($output_roles) { + push @lines, "$address ($role)"; + } else { + push @lines, $address; + } + $saw{$address} = 1; + } + } + + return @lines; +} + sub output { my @parms = @_;
Signature · 1 line
1.6.4.3
Joe Perches
maintainerQuoted 2 lines · Ben Hutchings
Add the output option '--roles' to get_maintainer.pl. This causes it to show the role of each email address, i.e. why it was selected.
Hi Ben.
Interesting idea.
This patch applies with offsets against the latest version that Andrew Morton has in his tree.
Here are the patches I posted a few days ago:
http://lkml.org/lkml/2009/10/10/11
Are the email addresses generated going
to be acceptable to all mailers or is --roles
just used for visual inspection?
Have you tested it with
git-send-email --cc-cmd "scripts/get_maintainer.pl --roles" ?
Trivial comment:
Quoted 1 line
+
push_email_address($line, 'signed-off');
[]
Quoted 1 line
+
push_email_address($line, 'blamed');
The "signed-off" role though isn't necessarily
an actual "Signed-off-by:". It could be an
"Acked-by:", or "tested-by:", or "reviewed-By:".
And the "blamed" keyword may be unnecessarily negative.
Maybe it could be "git-signer" and "modified-author"
cheers, Joe