summaryrefslogtreecommitdiffstats
path: root/scripts/send-pull-request
diff options
context:
space:
mode:
authorDarren Hart <dvhart@linux.intel.com>2010-12-21 14:54:10 -0800
committerRichard Purdie <rpurdie@linux.intel.com>2010-12-23 14:20:50 +0000
commit585c506cd8698948b9e970ebdbf96b99286fb05d (patch)
tree71d4b532963457b79b86a27de08244feba82a95b /scripts/send-pull-request
parenteca21e63590c165c5aaf14cbd51c7f325b731aba (diff)
downloadpoky-585c506cd8698948b9e970ebdbf96b99286fb05d.tar.gz
send-pull-request: allow users to select git-send-email or sendmail
Some users find it easier to use their git sendmail setup over a local MTA to deliver mail with the send-pull-request script. If you would like to do this, please read the git-send-email man page and set the relevant entries in your git config. In particular, be sure to set sendemail.from to avoid being asked each time. Reported-by: Khem Raj <raj.khem@gmail.com> CC: Bruce Ashfield <bruce.ashfield@windriver.com> Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Diffstat (limited to 'scripts/send-pull-request')
-rwxr-xr-xscripts/send-pull-request69
1 files changed, 50 insertions, 19 deletions
diff --git a/scripts/send-pull-request b/scripts/send-pull-request
index 03a78f9b1e..9872c0dc65 100755
--- a/scripts/send-pull-request
+++ b/scripts/send-pull-request
@@ -1,6 +1,11 @@
1#!/bin/bash 1#!/bin/bash
2AUTO=0 2AUTO=0
3 3
4# Check env for any default settings, command line options will override these.
5if [ -z "$PULL_MTA" ]; then
6 PULL_MTA="sendmail"
7fi
8
4usage() 9usage()
5{ 10{
6cat <<EOM 11cat <<EOM
@@ -8,6 +13,7 @@ Usage: $(basename $0) [-h] [-a] [[-t email]...] -p pull-dir
8 -t email Explicitly add email to the recipients 13 -t email Explicitly add email to the recipients
9 -a Automatically harvest recipients from "*-by: email" lines 14 -a Automatically harvest recipients from "*-by: email" lines
10 in the patches in the pull-dir 15 in the patches in the pull-dir
16 -g Use git-send-email to send mail instead of sendmail
11 -p pull-dir Directory containing summary and patch files 17 -p pull-dir Directory containing summary and patch files
12EOM 18EOM
13} 19}
@@ -35,11 +41,14 @@ harvest_recipients()
35 41
36 42
37# Parse and verify arguments 43# Parse and verify arguments
38while getopts "ahp:t:" OPT; do 44while getopts "aghp:t:" OPT; do
39 case $OPT in 45 case $OPT in
40 a) 46 a)
41 AUTO=1 47 AUTO=1
42 ;; 48 ;;
49 g)
50 PULL_MTA="git"
51 ;;
43 h) 52 h)
44 usage 53 usage
45 exit 0 54 exit 0
@@ -111,25 +120,47 @@ read cont
111 120
112if [ "$cont" == "y" ] || [ "$cont" == "Y" ]; then 121if [ "$cont" == "y" ] || [ "$cont" == "Y" ]; then
113 ERROR=0 122 ERROR=0
114 for PATCH in $PDIR/*patch; do 123 case "$PULL_MTA" in
115 # Insert To and CC headers via formail to keep them separate and 124 git)
116 # appending them to the sendmail command as -- $TO $CC has proven 125 export IFS=$','
117 # to be an exercise in futility. 126 GIT_TO=$(for R in $TO; do echo -n "--to='$R' "; done)
118 # 127 GIT_CC=$(for R in $CC; do echo -n "--cc='$R' "; done)
119 # Use tail to remove the email envelope from git or formail as 128 unset IFS
120 # msmtp (sendmail) would choke on them. 129 for PATCH in $PDIR/*patch; do
121 # 130 # We harvest the emails manually, so force git not to.
122 # Modify the patch date for sequential delivery, but retain the 131 eval "git send-email $GIT_TO $GIT_CC --no-chain-reply-to --suppress-cc=all $PATCH"
123 # original date as "Old-Date". 132 if [ $? -eq 1 ]; then
124 DATE=$(date +"%a, %d %b %Y %k:%M:%S %z") 133 ERROR=1
125 cat $PATCH | formail -I "To: $TO" -I "CC: $CC" -i "Date: $DATE" | tail -n +2 | sendmail -t 134 fi
126 if [ $? -eq 1 ]; then 135 done
127 ERROR=1 136 ;;
128 fi 137 sendmail)
129 done 138 for PATCH in $PDIR/*patch; do
139 # Insert To and CC headers via formail to keep them separate and
140 # appending them to the sendmail command as -- $TO $CC has
141 # proven to be an exercise in futility.
142 #
143 # Use tail to remove the email envelope from git or formail as
144 # msmtp (sendmail) would choke on them.
145 #
146 # Modify the patch date for sequential delivery, but retain the
147 # original date as "Old-Date".
148 DATE=$(date +"%a, %d %b %Y %k:%M:%S %z")
149 cat $PATCH | formail -I "To: $TO" -I "CC: $CC" -i "Date: $DATE" | tail -n +2 | sendmail -t
150 if [ $? -eq 1 ]; then
151 ERROR=1
152 fi
153 done
154 ;;
155 *)
156 echo "ERROR: unknown MTA: $PULL_MTA"
157 usage
158 exit 1
159 ;;
160 esac
161
130 if [ $ERROR -eq 1 ]; then 162 if [ $ERROR -eq 1 ]; then
131 echo "ERROR: sendmail failed to send one or more messages. Check your" 163 echo "ERROR: Failed to send one or more messages. Check your MTA log for details."
132 echo " sendmail log for details."
133 fi 164 fi
134else 165else
135 echo "Send aborted." 166 echo "Send aborted."