summaryrefslogtreecommitdiffstats
path: root/scripts/send-pull-request
diff options
context:
space:
mode:
authorDarren Hart <dvhart@linux.intel.com>2011-05-13 13:58:36 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-05-19 23:40:39 +0100
commit2b56f7b8c60290a09a27cc764bc420efbbe373d3 (patch)
tree2a573beed101839f33870fde29abc5e6932c3ba5 /scripts/send-pull-request
parentad6335ac7b5c37a1123058d0db33a5ba67e58521 (diff)
downloadpoky-2b56f7b8c60290a09a27cc764bc420efbbe373d3.tar.gz
send-pull-request: don't send all patches to everyone even with -a
Rather than sending every patch to every recipient of the entire series when -a is used, only send the cover letter to everyone and use git's --signed-off-by-cc feature to generate an auto cc list for the individual patches. Add a -c option to use --signed-off-by-cc to auto cc recipeients at the individual patch level. This is implied by -a. Using git to harvest the Cc list means only collecting Signed-off-by and Cc lines, rather than the more generic *-by lines previously. This is a fair trade-off for significantly reduced complexity. If users want to add Acked-by and Tested-by lines and want to use the -a feature, they should include those recipients as Cc lines as well. Now that we rely on git for auto-cc for the individual patches, make sure the user is prompted before sending each patch by forcing --confirm=always. (From OE-Core rev: 90ef7136087f1a16da3c8fc2decbed27a5debcd8) Signed-off-by: Darren Hart <dvhart@linux.intel.com> Acked-by: Otavio Salvador <otavio@ossystems.com.br> Cc: Khem Raj <raj.khem@gmail.com> Cc: Koen Kooi <koen@dominion.thruhere.net> Cc: Otavio Salvador <otavio@ossystems.com.br> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/send-pull-request')
-rwxr-xr-xscripts/send-pull-request75
1 files changed, 47 insertions, 28 deletions
diff --git a/scripts/send-pull-request b/scripts/send-pull-request
index b294d35bd5..5a11d1f1e6 100755
--- a/scripts/send-pull-request
+++ b/scripts/send-pull-request
@@ -1,36 +1,40 @@
1#!/bin/bash 1#!/bin/bash
2AUTO=0 2AUTO=0
3AUTO_CL=0
3 4
4# Prevent environment leakage to these vars. 5# Prevent environment leakage to these vars.
5unset TO 6unset TO
6unset CC 7unset CC
8unset AUTO_CC
7 9
8usage() 10usage()
9{ 11{
10cat <<EOM 12cat <<EOM
11Usage: $(basename $0) [-h] [-a] [[-t email]...] -p pull-dir 13Usage: $(basename $0) [-h] [-a] [-c] [[-t email]...] -p pull-dir
12 -t email Explicitly add email to the recipients 14 -a Send the cover letter to every recipient listed in Cc and
13 -a Automatically harvest recipients from "*-by: email" lines 15 Signed-off-by lines found in the cover letter and the patches.
14 in the patches in the pull-dir 16 This option implies -c.
17 -c Expand the Cc list for the individual patches using the Cc and
18 Signed-off-by lines from the same patch.
15 -p pull-dir Directory containing summary and patch files 19 -p pull-dir Directory containing summary and patch files
20 -t email Explicitly add email to the recipients
16EOM 21EOM
17} 22}
18 23
19# Collect To and CC addresses from the patch files if they exist 24# Collect addresses from a patch into AUTO_CC
20# $1: Which header to add the recipients to, "TO" or "CC" 25# $1: a patch file
21# $2: The regex to match and strip from the line with email addresses
22harvest_recipients() 26harvest_recipients()
23{ 27{
24 TO_CC=$1 28 PATCH=$1
25 REGX=$2
26 export IFS=$',\n' 29 export IFS=$',\n'
27 for PATCH in $PDIR/*.patch; do 30 for REGX in "^[Cc][Cc]: *" "^[Ss]igned-[Oo]ff-[Bb]y: *"; do
28 # Grab To addresses
29 for EMAIL in $(sed '/^---$/q' $PATCH | grep -e "$REGX" | sed "s/$REGX//"); do 31 for EMAIL in $(sed '/^---$/q' $PATCH | grep -e "$REGX" | sed "s/$REGX//"); do
30 if [ "$TO_CC" == "TO" ] && [ "${TO/$EMAIL/}" == "$TO" ] && [ -n "$EMAIL" ]; then 32 if [ "${AUTO_CC/$EMAIL/}" == "$AUTO_CC" ] && [ -n "$EMAIL" ]; then
31 if [ -z "$TO" ]; then TO=$EMAIL; else TO="$TO,$EMAIL"; fi 33 if [ -z "$AUTO_CC" ]; then
32 elif [ "$TO_CC" == "CC" ] && [ "${CC/$EMAIL/}" == "$CC" ] && [ -n "$EMAIL" ]; then 34 AUTO_CC=$EMAIL;
33 if [ -z "$CC" ]; then CC=$EMAIL; else CC="$CC,$EMAIL"; fi 35 else
36 AUTO_CC="$AUTO_CC,$EMAIL";
37 fi
34 fi 38 fi
35 done 39 done
36 done 40 done
@@ -39,9 +43,13 @@ harvest_recipients()
39 43
40 44
41# Parse and verify arguments 45# Parse and verify arguments
42while getopts "ahp:t:" OPT; do 46while getopts "achp:t:" OPT; do
43 case $OPT in 47 case $OPT in
44 a) 48 a)
49 AUTO_CL=1
50 AUTO=1
51 ;;
52 c)
45 AUTO=1 53 AUTO=1
46 ;; 54 ;;
47 h) 55 h)
@@ -84,13 +92,11 @@ for TOKEN in SUBJECT BLURB; do
84done 92done
85 93
86 94
87# Harvest emails from the generated patches and populate the TO and CC variables 95# Harvest emails from the generated patches and populate AUTO_CC.
88# In addition to To and CC headers/lines, the common Signed-off-by, Tested-by, 96if [ $AUTO_CL -eq 1 ]; then
89# etc. (*-by) will be added to CC. 97 for PATCH in $PDIR/*.patch; do
90if [ $AUTO -eq 1 ]; then 98 harvest_recipients $PATCH
91 harvest_recipients TO "^[Tt][Oo]: *" 99 done
92 harvest_recipients CC "^[Cc][Cc]: *"
93 harvest_recipients CC "^[A-Z][A-Za-z-]*-[Bb][Yy]: *"
94fi 100fi
95 101
96AUTO_TO="$(git config sendemail.to)" 102AUTO_TO="$(git config sendemail.to)"
@@ -102,7 +108,7 @@ if [ -n "$AUTO_TO" ]; then
102 fi 108 fi
103fi 109fi
104 110
105if [ -z "$TO" ] && [ -z "$CC" ]; then 111if [ -z "$TO" ] && [ -z "$AUTO_CC" ]; then
106 echo "ERROR: you have not specified any recipients." 112 echo "ERROR: you have not specified any recipients."
107 usage 113 usage
108 exit 1 114 exit 1
@@ -114,7 +120,8 @@ cat <<EOM
114The following patches: 120The following patches:
115$(for PATCH in $PDIR/*.patch; do echo " $PATCH"; done) 121$(for PATCH in $PDIR/*.patch; do echo " $PATCH"; done)
116 122
117will now be sent via the git send-email command. 123will now be sent via the git send-email command. Git will prompt you before
124sending any email.
118 125
119EOM 126EOM
120echo "Continue? [y/N] " 127echo "Continue? [y/N] "
@@ -124,11 +131,23 @@ if [ "$cont" == "y" ] || [ "$cont" == "Y" ]; then
124 ERROR=0 131 ERROR=0
125 export IFS=$',' 132 export IFS=$','
126 GIT_TO=$(for R in $TO; do echo -n "--to='$R' "; done) 133 GIT_TO=$(for R in $TO; do echo -n "--to='$R' "; done)
127 GIT_CC=$(for R in $CC; do echo -n "--cc='$R' "; done) 134 GIT_CC=$(for R in $AUTO_CC; do echo -n "--cc='$R' "; done)
128 unset IFS 135 unset IFS
129 for PATCH in $PDIR/*patch; do 136 for PATCH in $PDIR/*patch; do
130 # We harvest the emails manually, so force git not to. 137 if [ $AUTO -eq 1 ]; then
131 eval "git send-email $GIT_TO $GIT_CC --no-chain-reply-to --suppress-cc=all $PATCH" 138 if [ $PATCH == "$CL" ] && [ $AUTO_CL -eq 1 ]; then
139 # Send the cover letter to every recipient, both
140 # specified as well as harvested.
141 eval "git send-email $GIT_TO $GIT_CC --confirm=always --no-chain-reply-to --suppress-cc=all $PATCH"
142 else
143 # Send the patch to the specified recipients and
144 # those git finds in this specific patch.
145 eval "git send-email $GIT_TO --confirm=always --no-chain-reply-to --signed-off-by-cc $PATCH"
146 fi
147 else
148 # Only send to the explicitly specified recipients
149 eval "git send-email $GIT_TO --confirm=always --no-chain-reply-to --suppress-cc=all $PATCH"
150 fi
132 if [ $? -eq 1 ]; then 151 if [ $? -eq 1 ]; then
133 ERROR=1 152 ERROR=1
134 fi 153 fi