All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scripts/get_maintainer.pl: add role output option
@ 2009-10-15  3:51 Ben Hutchings
  2009-10-15  4:42 ` Joe Perches
  0 siblings, 1 reply; 2+ messages in thread
From: Ben Hutchings @ 2009-10-15  3:51 UTC (permalink / raw)
  To: Joe Perches; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 4918 bytes --]

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.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 scripts/get_maintainer.pl |   52 ++++++++++++++++++++++++++++++++-------------
 1 files changed, 37 insertions(+), 15 deletions(-)

diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index cdb44b6..591fd3d 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -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 = @_;
 
-- 
1.6.4.3



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] scripts/get_maintainer.pl: add role output option
  2009-10-15  3:51 [PATCH] scripts/get_maintainer.pl: add role output option Ben Hutchings
@ 2009-10-15  4:42 ` Joe Perches
  0 siblings, 0 replies; 2+ messages in thread
From: Joe Perches @ 2009-10-15  4:42 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: linux-kernel

On Thu, 2009-10-15 at 04:51 +0100, Ben Hutchings wrote:
> 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:

> + push_email_address($line, 'signed-off');
[] 
> + 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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-10-15  4:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-15  3:51 [PATCH] scripts/get_maintainer.pl: add role output option Ben Hutchings
2009-10-15  4:42 ` Joe Perches

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.