[OE-core] [PATCH 8/8] scripts/send-pull-request: Add CC selectively

Khem Raj raj.khem at gmail.com
Sat May 7 07:54:02 UTC 2011


Currently a consolidated pull request adds all the participants
to every patch, which in essence is good but might lose focus
of developers who would be interested to know about the patch
that developer contributed to. This patch fixes the script by
extracting the to and cc information from each patch one by one
and add it to patch mail header instead of doing a sweeping one
pass over all patches to collect all email addresses. It should
reduce some email traffic for developers.

Signed-off-by: Khem Raj <raj.khem at gmail.com>
---
 scripts/send-pull-request |   51 +++++++++++++++++++++++++-------------------
 1 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/scripts/send-pull-request b/scripts/send-pull-request
index 3af2a9f..36a89f4 100755
--- a/scripts/send-pull-request
+++ b/scripts/send-pull-request
@@ -29,24 +29,38 @@ EOM
 # Collect To and CC addresses from the patch files if they exist
 # $1: Which header to add the recipients to, "TO" or "CC"
 # $2: The regex to match and strip from the line with email addresses
+# $3: The patch which we are preparing to send
 harvest_recipients()
 {
     TO_CC=$1
     REGX=$2
+    PATCH=$3
     export IFS=$',\n'
-    for PATCH in $PDIR/*.patch; do
-        # Grab To addresses
-        for EMAIL in $(sed '/^---$/q' $PATCH | grep -e "$REGX" | sed "s/$REGX//"); do
-            if [ "$TO_CC" == "TO" ] && [ "${TO/$EMAIL/}" == "$TO" ] && [ -n "$EMAIL" ]; then
-                if [ -z "$TO" ]; then TO=$EMAIL; else TO="$TO,$EMAIL"; fi
-            elif [ "$TO_CC" == "CC" ] && [ "${CC/$EMAIL/}" == "$CC" ] && [ -n "$EMAIL" ]; then
-                if [ -z "$CC" ]; then CC=$EMAIL; else CC="$CC,$EMAIL"; fi
-            fi
-        done
+    # Grab To addresses
+    for EMAIL in $(sed '/^---$/q' $PATCH | grep -e "$REGX" | sed "s/$REGX//"); do
+        if [ "$TO_CC" == "TO" ] && [ "${TO/$EMAIL/}" == "$TO" ] && [ -n "$EMAIL" ]; then
+           if [ -z "$TO" ]; then TO=$EMAIL; else TO="$TO,$EMAIL"; fi
+        elif [ "$TO_CC" == "CC" ] && [ "${CC/$EMAIL/}" == "$CC" ] && [ -n "$EMAIL" ]; then
+           if [ -z "$CC" ]; then CC=$EMAIL; else CC="$CC,$EMAIL"; fi
+        fi
     done
     unset IFS
 }
 
+# $1: The given patch
+create_recipient_lists()
+{
+    THEPATCH=$1
+    # Harvest emails from the generated patch and populate the TO and CC variables
+    # In addition to To and CC headers/lines, the common Signed-off-by, Tested-by,
+    # etc. (*-by) will be added to CC.
+    if [ $AUTO -eq 1 ]; then
+        harvest_recipients TO "^[Tt][Oo]: *" $THEPATCH
+        harvest_recipients CC "^[Cc][Cc]: *" $THEPATCH
+        harvest_recipients CC "^.*-[Bb][Yy]: *" $THEPATCH
+    fi
+}
+
 
 # Parse and verify arguments
 while getopts "af:ghp:t:" OPT; do
@@ -100,15 +114,6 @@ for TOKEN in SUBJECT BLURB; do
 done
 
 
-# Harvest emails from the generated patches and populate the TO and CC variables
-# In addition to To and CC headers/lines, the common Signed-off-by, Tested-by,
-# etc. (*-by) will be added to CC.
-if [ $AUTO -eq 1 ]; then
-    harvest_recipients TO "^[Tt][Oo]: *"
-    harvest_recipients CC "^[Cc][Cc]: *"
-    harvest_recipients CC "^.*-[Bb][Yy]: *"
-fi
-
 case "$PULL_MTA" in
     git)
         FROM="$(git config sendemail.from)"
@@ -158,11 +163,12 @@ if [ "$cont" == "y" ] || [ "$cont" == "Y" ]; then
     ERROR=0
     case "$PULL_MTA" in
         git)
-            export IFS=$','
-            GIT_TO=$(for R in $TO; do echo -n "--to='$R' "; done)
-            GIT_CC=$(for R in $CC; do echo -n "--cc='$R' "; done)
-            unset IFS
             for PATCH in $PDIR/*patch; do
+                create_recipient_lists $PATCH
+                export IFS=$','
+                GIT_TO=$(for R in $TO; do echo -n "--to='$R' "; done)
+                GIT_CC=$(for R in $CC; do echo -n "--cc='$R' "; done)
+                unset IFS
                 # We harvest the emails manually, so force git not to.
                 eval "git send-email $GIT_TO $GIT_CC --no-chain-reply-to --suppress-cc=all $PATCH"
                 if [ $? -eq 1 ]; then
@@ -172,6 +178,7 @@ if [ "$cont" == "y" ] || [ "$cont" == "Y" ]; then
             ;;
         sendmail)
             for PATCH in $PDIR/*patch; do
+                create_recipient_lists $PATCH
                 # Insert To and CC headers via formail to keep them separate and
                 # appending them to the sendmail command as -- $TO $CC has
                 # proven to be an exercise in futility.
-- 
1.7.4.1





More information about the Openembedded-core mailing list