All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] get_maintainer.pl: Add support to match arbitrary text
@ 2011-01-24 23:32 L. Alberto Giménez
  2011-01-24 23:53 ` Joe Perches
  2011-01-25 14:23 ` [PATCH] get_maintainer.pl: Add support to match arbitrary text Joe Perches
  0 siblings, 2 replies; 8+ messages in thread
From: L. Alberto Giménez @ 2011-01-24 23:32 UTC (permalink / raw)
  To: linux-kernel
  Cc: L. Alberto Giménez, Andrew Morton, Joe Perches,
	David S. Miller, Florian Mickler, Stephen Hemminger,
	Wolfram Sang

Extend the usage of the K section in the MAINTAINERS file to support matching
regular expressions with the content that precedes the patch (delimited by three
dashes "---").

The change enables the get_maintainer.pl script to get maintainers based on
arbitrary text that may precede the patch itself (for example, the commit
message or mail headers generated by git-format-patch)

Thanks to Jesper Juhl to point me that trivial patches should be CC'd to Jiri.
The idea is that the get_maintainer.pl can detect such situations and add the
additional email addresses and let the MAINTAINERS file handle who should get
copies of what.

Signed-off-by: L. Alberto Giménez <agimenez@sysvalve.es>
---
 MAINTAINERS               |    1 +
 scripts/get_maintainer.pl |   12 +++++++++++-
 2 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index cf0f3a5..c1e33ac 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6145,6 +6145,7 @@ TRIVIAL PATCHES
 M:	Jiri Kosina <trivial@kernel.org>
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial.git
 S:	Maintained
+K:	^Subject:.*\[(?i)trivial\].*
 
 TTY LAYER
 M:	Greg Kroah-Hartman <gregkh@suse.de>
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index 139e0ff..63d4d90 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -420,6 +420,11 @@ foreach my $file (@ARGV) {
 
 	open(my $patch, "< $file")
 	    or die "$P: Can't open $file: $!\n";
+
+	# We can add arbitrary information before the patch itself (commit message,
+	# mail headers,... This allows us to match arbitrary keywords agains any
+	# part of a git-format-patch generated file (subject tags, etc...)
+	my $in_patch = 0;
 	while (<$patch>) {
 	    my $patch_line = $_;
 	    if (m/^\+\+\+\s+(\S+)/) {
@@ -432,9 +437,14 @@ foreach my $file (@ARGV) {
 		if ($email_git_blame) {
 		    push(@range, "$lastfile:$1:$2");
 		}
+		} elsif (not $in_patch and m/^---/) {
+			# enter "patch area": keywords matched only on changed lines
+			$in_patch = 1;
 	    } elsif ($keywords) {
 		foreach my $line (keys %keyword_hash) {
-		    if ($patch_line =~ m/^[+-].*$keyword_hash{$line}/x) {
+			my $change_hook = $in_patch ? "^[+-].*" : "";
+
+			if ($patch_line =~ m/^${change_hook}$keyword_hash{$line}/x) {
 			push(@keyword_tvi, $line);
 		    }
 		}
-- 
1.7.4.rc0.5.gf2665


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

* Re: [PATCH] get_maintainer.pl: Add support to match arbitrary text
  2011-01-24 23:32 [PATCH] get_maintainer.pl: Add support to match arbitrary text L. Alberto Giménez
@ 2011-01-24 23:53 ` Joe Perches
  2011-01-25  0:25   ` L. Alberto Giménez
  2011-01-25 14:23 ` [PATCH] get_maintainer.pl: Add support to match arbitrary text Joe Perches
  1 sibling, 1 reply; 8+ messages in thread
From: Joe Perches @ 2011-01-24 23:53 UTC (permalink / raw)
  To: L. Alberto Giménez
  Cc: linux-kernel, Andrew Morton, David S. Miller, Florian Mickler,
	Stephen Hemminger, Wolfram Sang

On Tue, 2011-01-25 at 00:32 +0100, L. Alberto Giménez wrote:
> Extend the usage of the K section in the MAINTAINERS file to support matching
> regular expressions with the content that precedes the patch (delimited by three
> dashes "---").
> +		} elsif (not $in_patch and m/^---/) {
> +			# enter "patch area": keywords matched only on changed lines
> +			$in_patch = 1;

Not all patches need or have ---

This would be better as "^---$"



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

* Re: [PATCH] get_maintainer.pl: Add support to match arbitrary text
  2011-01-24 23:53 ` Joe Perches
@ 2011-01-25  0:25   ` L. Alberto Giménez
  2011-01-25 14:08     ` [PATCH] get_maintainer.pl: Allow "K:" pattern tests to match non-patch text Joe Perches
  0 siblings, 1 reply; 8+ messages in thread
From: L. Alberto Giménez @ 2011-01-25  0:25 UTC (permalink / raw)
  To: Joe Perches
  Cc: linux-kernel, Andrew Morton, David S. Miller, Florian Mickler,
	Stephen Hemminger, Wolfram Sang

On Mon, Jan 24, 2011 at 03:53:46PM -0800, Joe Perches wrote:
> On Tue, 2011-01-25 at 00:32 +0100, L. Alberto Giménez wrote:
> > Extend the usage of the K section in the MAINTAINERS file to support matching
> > regular expressions with the content that precedes the patch (delimited by three
> > dashes "---").
> > +		} elsif (not $in_patch and m/^---/) {
> > +			# enter "patch area": keywords matched only on changed lines
> > +			$in_patch = 1;
> 
> Not all patches need or have ---
> 
> This would be better as "^---$"

Hi Joe,

As I replied to you previously, please feel free to fix the patch. Most of the
patches I've seen use that line as a separator. Could you please give me the
right regexp to detect the beginning of patches?

On the other hand, if it's not properly detected, it will just match the "K"
keywords against all the patch lines (not just deleted or added lines). For a
standard unified diff format that would be 3 context lines that should match
with something like "^Subject: whatever". Again, it's just a proposal waiting
for comments/enhancements.

The idea here was to enable "triggers" in the subject to add the proper CCs. It
just ended up in a "match anything against the file content" change.

Regards,
-- 
L. Alberto Giménez
JabberID agimenez@jabber.sysvalve.es
GnuPG key ID 0x3BAABDE1

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

* [PATCH] get_maintainer.pl: Allow "K:" pattern tests to match non-patch text
  2011-01-25  0:25   ` L. Alberto Giménez
@ 2011-01-25 14:08     ` Joe Perches
  2011-01-25 18:44       ` L. Alberto Giménez
  0 siblings, 1 reply; 8+ messages in thread
From: Joe Perches @ 2011-01-25 14:08 UTC (permalink / raw)
  To: L. Alberto Giménez
  Cc: linux-kernel, Andrew Morton, David S. Miller, Florian Mickler,
	Stephen Hemminger, Wolfram Sang

Extend the usage of the K section in the MAINTAINERS file to support matching
regular expressions to any arbitrary text that may precede the patch itself.
For example, the commit message or mail headers generated by git-format-patch.

Original-patch-by: L. Alberto Giménez <agimenez@sysvalve.es>
Signed-off-by: Joe Perches <joe@perches.com>

---

> On Tue, 2011-01-25 at 01:25 +0100, L. Alberto Giménez wrote:
> feel free to fix the patch.

 scripts/get_maintainer.pl |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index 139e0ff..d29a8d7 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -420,6 +420,14 @@ foreach my $file (@ARGV) {
 
 	open(my $patch, "< $file")
 	    or die "$P: Can't open $file: $!\n";
+
+	# We can check arbitrary information before the patch
+	# like the commit message, mail headers, etc...
+	# This allows us to match arbitrary keywords against any part
+	# of a git format-patch generated file (subject tags, etc...)
+
+	my $patch_prefix = "";			#Parsing the intro
+
 	while (<$patch>) {
 	    my $patch_line = $_;
 	    if (m/^\+\+\+\s+(\S+)/) {
@@ -428,13 +436,14 @@ foreach my $file (@ARGV) {
 		$filename =~ s@\n@@;
 		$lastfile = $filename;
 		push(@files, $filename);
+		$patch_prefix = "^[+-].*";	#Now parsing the actual patch
 	    } elsif (m/^\@\@ -(\d+),(\d+)/) {
 		if ($email_git_blame) {
 		    push(@range, "$lastfile:$1:$2");
 		}
 	    } elsif ($keywords) {
 		foreach my $line (keys %keyword_hash) {
-		    if ($patch_line =~ m/^[+-].*$keyword_hash{$line}/x) {
+		    if ($patch_line =~ m/${patch_prefix}$keyword_hash{$line}/x) {
 			push(@keyword_tvi, $line);
 		    }
 		}



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

* Re: [PATCH] get_maintainer.pl: Add support to match arbitrary text
  2011-01-24 23:32 [PATCH] get_maintainer.pl: Add support to match arbitrary text L. Alberto Giménez
  2011-01-24 23:53 ` Joe Perches
@ 2011-01-25 14:23 ` Joe Perches
  1 sibling, 0 replies; 8+ messages in thread
From: Joe Perches @ 2011-01-25 14:23 UTC (permalink / raw)
  To: L. Alberto Giménez
  Cc: linux-kernel, Andrew Morton, David S. Miller, Florian Mickler,
	Stephen Hemminger, Wolfram Sang

On Tue, 2011-01-25 at 00:32 +0100, L. Alberto Giménez wrote:
> Signed-off-by: L. Alberto Giménez <agimenez@sysvalve.es>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index cf0f3a5..c1e33ac 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -6145,6 +6145,7 @@ TRIVIAL PATCHES
>  M:	Jiri Kosina <trivial@kernel.org>
>  T:	git git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial.git
>  S:	Maintained
> +K:	^Subject:.*\[(?i)trivial\].*

The trailing .* isn't necessary.

This matches just case insensitive "[trivial]".

Looking at the trivial patches posted:
https://patchwork.kernel.org/project/LKML/list/?q=trivial
that's not a very good matching pattern.

Maybe this is better:

K:	^(?i:subject):.*(?i:trivial)\s*[:,\]]



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

* Re: [PATCH] get_maintainer.pl: Allow "K:" pattern tests to match non-patch text
  2011-01-25 14:08     ` [PATCH] get_maintainer.pl: Allow "K:" pattern tests to match non-patch text Joe Perches
@ 2011-01-25 18:44       ` L. Alberto Giménez
  2011-01-25 18:58         ` Joe Perches
  0 siblings, 1 reply; 8+ messages in thread
From: L. Alberto Giménez @ 2011-01-25 18:44 UTC (permalink / raw)
  To: Joe Perches
  Cc: linux-kernel, Andrew Morton, David S. Miller, Florian Mickler,
	Stephen Hemminger, Wolfram Sang

On Tue, Jan 25, 2011 at 06:08:49AM -0800, Joe Perches wrote:
> Extend the usage of the K section in the MAINTAINERS file to support matching
> regular expressions to any arbitrary text that may precede the patch itself.
> For example, the commit message or mail headers generated by git-format-patch.
> 
> Original-patch-by: L. Alberto Giménez <agimenez@sysvalve.es>
> Signed-off-by: Joe Perches <joe@perches.com>

Hey, am I supposed to Ack it or something like that?
-- 
L. Alberto Giménez
JabberID agimenez@jabber.sysvalve.es
GnuPG key ID 0x3BAABDE1

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

* Re: [PATCH] get_maintainer.pl: Allow "K:" pattern tests to match non-patch text
  2011-01-25 18:44       ` L. Alberto Giménez
@ 2011-01-25 18:58         ` Joe Perches
  2011-01-26 12:23           ` "L. Alberto Giménez"
  0 siblings, 1 reply; 8+ messages in thread
From: Joe Perches @ 2011-01-25 18:58 UTC (permalink / raw)
  To: L. Alberto Giménez
  Cc: linux-kernel, Andrew Morton, David S. Miller, Florian Mickler,
	Stephen Hemminger, Wolfram Sang

On Tue, 2011-01-25 at 19:44 +0100, L. Alberto Giménez wrote:
> On Tue, Jan 25, 2011 at 06:08:49AM -0800, Joe Perches wrote:
> > Extend the usage of the K section in the MAINTAINERS file to support matching
> > regular expressions to any arbitrary text that may precede the patch itself.
> > For example, the commit message or mail headers generated by git-format-patch.
> > Original-patch-by: L. Alberto Giménez <agimenez@sysvalve.es>
> > Signed-off-by: Joe Perches <joe@perches.com>
> Hey, am I supposed to Ack it or something like that?

You can if you want, you don't have to.


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

* Re: [PATCH] get_maintainer.pl: Allow "K:" pattern tests to match non-patch text
  2011-01-25 18:58         ` Joe Perches
@ 2011-01-26 12:23           ` "L. Alberto Giménez"
  0 siblings, 0 replies; 8+ messages in thread
From: "L. Alberto Giménez" @ 2011-01-26 12:23 UTC (permalink / raw)
  To: Joe Perches
  Cc: linux-kernel, Andrew Morton, David S. Miller, Florian Mickler,
	Stephen Hemminger, Wolfram Sang

On 25/01/2011 19:58, Joe Perches wrote:
> On Tue, 2011-01-25 at 19:44 +0100, L. Alberto Giménez wrote:
>> On Tue, Jan 25, 2011 at 06:08:49AM -0800, Joe Perches wrote:
>>> Extend the usage of the K section in the MAINTAINERS file to support matching
>>> regular expressions to any arbitrary text that may precede the patch itself.
>>> For example, the commit message or mail headers generated by git-format-patch.
>>> Original-patch-by: L. Alberto Giménez<agimenez@sysvalve.es>
>>> Signed-off-by: Joe Perches<joe@perches.com>
>> Hey, am I supposed to Ack it or something like that?
> You can if you want, you don't have to.

If it's of any use:

Acked-by: L. Alberto Giménez <agimenez@sysvalve.es>

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

end of thread, other threads:[~2011-01-26 12:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-24 23:32 [PATCH] get_maintainer.pl: Add support to match arbitrary text L. Alberto Giménez
2011-01-24 23:53 ` Joe Perches
2011-01-25  0:25   ` L. Alberto Giménez
2011-01-25 14:08     ` [PATCH] get_maintainer.pl: Allow "K:" pattern tests to match non-patch text Joe Perches
2011-01-25 18:44       ` L. Alberto Giménez
2011-01-25 18:58         ` Joe Perches
2011-01-26 12:23           ` "L. Alberto Giménez"
2011-01-25 14:23 ` [PATCH] get_maintainer.pl: Add support to match arbitrary text 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.