Re: [Xen-devel] [PATCH v6] scripts/add_maintainers.pl: New script

2018-05-16 Thread Ian Jackson
George Dunlap writes ("Re: [PATCH v6] scripts/add_maintainers.pl: New script"):
> I've looked over the help and approve of the functionality, and tested
> it for my use case and it seems to work as advertised.
> 
> On that basis:
> 
> Acked-by: George Dunlap 

Thanks, pushed.

Ian.

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH v6] scripts/add_maintainers.pl: New script

2018-05-16 Thread George Dunlap
On 05/16/2018 12:50 PM, Ian Jackson wrote:
> George Dunlap writes ("Re: [PATCH v6] scripts/add_maintainers.pl: New 
> script"):
>>> Changes since v5:
>>> - Add mention of --get-maintainers, and its best use case, to --help
>>>   output.  (Move $get_maintainer up so that it can be used here.)
>>
>> Do you actually want to check this massive changelog into the git repo?
> 
> No.  Lars used a nonstandard form for the `changes in vN' information
> and I decided not to reformat it.  I will strip it out when I commit
> to staging.

Great, thanks. :-)

I've looked over the help and approve of the functionality, and tested
it for my use case and it seems to work as advertised.

On that basis:

Acked-by: George Dunlap 

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH v6] scripts/add_maintainers.pl: New script

2018-05-16 Thread Ian Jackson
George Dunlap writes ("Re: [PATCH v6] scripts/add_maintainers.pl: New script"):
> > Changes since v5:
> > - Add mention of --get-maintainers, and its best use case, to --help
> >   output.  (Move $get_maintainer up so that it can be used here.)
> 
> Do you actually want to check this massive changelog into the git repo?

No.  Lars used a nonstandard form for the `changes in vN' information
and I decided not to reformat it.  I will strip it out when I commit
to staging.

Ian.

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH v6] scripts/add_maintainers.pl: New script

2018-05-16 Thread George Dunlap
On 05/15/2018 06:23 PM, Ian Jackson wrote:
> From: Lars Kurth 
> 
> This provides a much better workflow when using git format-patch and
> git send-email, with get_maintainer.pl.
> 
> The tool covers step 2 of the following workflow
> 
>   Step 1: git format-patch ... -o  ...
>   Step 2: ./scripts/add_maintainers.pl -d 
>   This overwrites  *.patch files in 
>   Step 3: git send-email -to xen-devel@lists.xenproject.org 
> /*.patchxm
> 
> I manually tested all options and the most common combinations
> on Mac.
> 
> Changes since v1:
> - Added RAB (indicated by Juergen on IRC that this is OK)
> - Remove trailing whitespaces
> - Renamed --prefix to --reroll-count
> - Cleaned up short options -v, ... to be in line with git
> - Added --tags|-t option to add AB, RAB and RB emails to CC list
> - Added --insert|-i mode to allow for people adding CCs to commit message
>   instead of the e-mail header (the header is the default)
> - Moved common code into functions
> - Added logic, such that the tool only insert's To: and Cc: statements
>   which were not there before, allowing for running the tool multiple times
>   on the same 
> 
> Changes since v2:
> - Deleted --version and related infrastructure
> - Added subroutine prototypes
> - Removed AT and @lists declaration and used \@ in literals
> - Changed usage message and options based on feedback
> - Improved error handling
> - Removed occurances of index() and replaced with regex
> - Removed non-perl idioms
> - Moved uniq statements to normalize and added info on what normalize does
> - Read L: tags from MAINTAINERS file instead of using heuristic
> - Fixed issues related to metacharacters in getmaintainers()
> - Allow multiple -a | --arg values (because of this renamed --args)
> - Identify tags via regex
> - CC's from tags are only inserted in the mail header, never the body
> - That is unless the new option --tagscc is used
> - Added policy processing which includes reworking insert()
> - Replaced -i|--insert with -p|--inspatch and -c|--inscover now using policies
> - Added new policies to cover for all user requests
> - Rewrote help message to center around usage of policies
> - Reordered some code (e.g. help string first to make code more easily 
> readable)
> 
> Changes since v3:
> - Made help message clearer
> - Replaced PROCESSING POLICY with LOCATION
> - Renamed --inspatch (top|ccbody|cc---|none) | -p (top|ccbody|cc---|none)
>   to --patchcc (header|commit|comment|none) | -p (header|commit|comment|none)
> - Renamed --inscover (top|ccend|none) | -c (top|ccend|none)
>   to --covercc (header|end|none) | -c (header|end|none)
> - Renamed variables and functions in the code to match the options
> - Changed $patch_prefix processing
> - Changed search expression for identifying cover letters
> - Renamed $readmailinglists to $getmailinglists_done
> - Use array form of open
> - More file error handling (using IO::Handle)
> - Fixed buggy AND in if statement
> - Removed check whether getmaintainers exists for future proofing
> - Add logic to work out --reroll-count
> 
> Changes since v4:
> - Strip some trailing whitespace from the code
> - writefile() now uses the .tmp-and-rename pattern to avoid data loss
> - Provide --get-maintainers= option to specify replacement for
>   get_maintainers.pl.  This is useful for Ian's usecase, since it
>   allows --get-maintainers=true, to avoid adding any MAINTAINERS-based
>   info anywhere while still adding other CCs (eg from -t) everywhere.
> - Refactor normalize() somewhat so that it uses only %seen, and
>   does not any longer modify its argument arrays.
> - De-dupe case-insensitively (by making normalize use lc).
> 
> Changes since v5:
> - Add mention of --get-maintainers, and its best use case, to --help
>   output.  (Move $get_maintainer up so that it can be used here.)

Do you actually want to check this massive changelog into the git repo?

 -George

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH v6] scripts/add_maintainers.pl: New script

2018-05-15 Thread Ian Jackson
From: Lars Kurth 

This provides a much better workflow when using git format-patch and
git send-email, with get_maintainer.pl.

The tool covers step 2 of the following workflow

  Step 1: git format-patch ... -o  ...
  Step 2: ./scripts/add_maintainers.pl -d 
  This overwrites  *.patch files in 
  Step 3: git send-email -to xen-devel@lists.xenproject.org /*.patchxm

I manually tested all options and the most common combinations
on Mac.

Changes since v1:
- Added RAB (indicated by Juergen on IRC that this is OK)
- Remove trailing whitespaces
- Renamed --prefix to --reroll-count
- Cleaned up short options -v, ... to be in line with git
- Added --tags|-t option to add AB, RAB and RB emails to CC list
- Added --insert|-i mode to allow for people adding CCs to commit message
  instead of the e-mail header (the header is the default)
- Moved common code into functions
- Added logic, such that the tool only insert's To: and Cc: statements
  which were not there before, allowing for running the tool multiple times
  on the same 

Changes since v2:
- Deleted --version and related infrastructure
- Added subroutine prototypes
- Removed AT and @lists declaration and used \@ in literals
- Changed usage message and options based on feedback
- Improved error handling
- Removed occurances of index() and replaced with regex
- Removed non-perl idioms
- Moved uniq statements to normalize and added info on what normalize does
- Read L: tags from MAINTAINERS file instead of using heuristic
- Fixed issues related to metacharacters in getmaintainers()
- Allow multiple -a | --arg values (because of this renamed --args)
- Identify tags via regex
- CC's from tags are only inserted in the mail header, never the body
- That is unless the new option --tagscc is used
- Added policy processing which includes reworking insert()
- Replaced -i|--insert with -p|--inspatch and -c|--inscover now using policies
- Added new policies to cover for all user requests
- Rewrote help message to center around usage of policies
- Reordered some code (e.g. help string first to make code more easily readable)

Changes since v3:
- Made help message clearer
- Replaced PROCESSING POLICY with LOCATION
- Renamed --inspatch (top|ccbody|cc---|none) | -p (top|ccbody|cc---|none)
  to --patchcc (header|commit|comment|none) | -p (header|commit|comment|none)
- Renamed --inscover (top|ccend|none) | -c (top|ccend|none)
  to --covercc (header|end|none) | -c (header|end|none)
- Renamed variables and functions in the code to match the options
- Changed $patch_prefix processing
- Changed search expression for identifying cover letters
- Renamed $readmailinglists to $getmailinglists_done
- Use array form of open
- More file error handling (using IO::Handle)
- Fixed buggy AND in if statement
- Removed check whether getmaintainers exists for future proofing
- Add logic to work out --reroll-count

Changes since v4:
- Strip some trailing whitespace from the code
- writefile() now uses the .tmp-and-rename pattern to avoid data loss
- Provide --get-maintainers= option to specify replacement for
  get_maintainers.pl.  This is useful for Ian's usecase, since it
  allows --get-maintainers=true, to avoid adding any MAINTAINERS-based
  info anywhere while still adding other CCs (eg from -t) everywhere.
- Refactor normalize() somewhat so that it uses only %seen, and
  does not any longer modify its argument arrays.
- De-dupe case-insensitively (by making normalize use lc).

Changes since v5:
- Add mention of --get-maintainers, and its best use case, to --help
  output.  (Move $get_maintainer up so that it can be used here.)

Cc: Andrew Cooper 
Cc: George Dunlap 
Cc: Ian Jackson 
Cc: Jan Beulich 
Cc: Julien Grall 
Cc: Konrad Rzeszutek Wilk 
Cc: Stefano Stabellini 
Cc: Tim Deegan 
Cc: Wei Liu 
Signed-off-by: Lars Kurth 
Release-acked-by: Juergen Gross 
Signed-off-by: Ian Jackson 
Acked-by: Lars Kurth 
---
 scripts/add_maintainers.pl | 555 +
 1 file changed, 555 insertions(+)
 create mode 100755 scripts/add_maintainers.pl

diff --git a/scripts/add_maintainers.pl b/scripts/add_maintainers.pl
new file mode 100755
index 000..99e4724
--- /dev/null
+++ b/scripts/add_maintainers.pl
@@ -0,0 +1,555 @@
+#!/usr/bin/perl -w
+# (c) 2018, Lars Kurth 
+#
+# Add maintainers to patches generated with git format-patch
+#
+# Usage: perl scripts/add_maintainers.pl [OPTIONS] -patchdir 
+#
+# Prerequisites: Execute
+#git format-patch ... -o  ...
+#
+#./scripts/get_maintainer.pl is present in the tree
+#
+# Licensed under the terms of the GNU GPL License version 2
+
+use strict;
+
+use Getopt::Long qw(:config no_auto_abbrev);
+use File::Basename;
+use List::MoreUtils qw(uniq);
+use IO::Handle;
+
+sub getmaintainers ($$$);
+sub gettagsfrompatch ($$$;$);
+sub normalize ($$);
+sub insert ();
+sub hastag ($$);
+
+# Tool Variables
+my $get_maintainer  = "./scripts/get_maintainer.pl";
+
+my $tool = $0;
+my $usage = <
+