summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarren Hart <dvhart@linux.intel.com>2011-05-13 13:33:57 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-05-19 23:40:38 +0100
commit58f901bf9128fa03211a7548d107722f5935ef1e (patch)
treee51dd0fca0891db4a08dabae238dc7fab6c81c17
parentb158757ef92f1e8bf62cf20bcb4d2bf2a212d6e0 (diff)
downloadpoky-58f901bf9128fa03211a7548d107722f5935ef1e.tar.gz
send-pull-request: remove local mta support
There is no real value in supporting sendmail directly when git can be configured to use it. The script used to generate the pull request mails relies heavily on git, so doing so here does not impose any additional dependencies and it greatly reduces the complexity of this script. (From OE-Core rev: 9674aa9a5bb497ab52aaa0ba5c97a87388163120) Signed-off-by: Darren Hart <dvhart@linux.intel.com> Acked-by: Otavio Salvador <otavio@ossystems.com.br> Cc: Otavio Salvador <otavio@ossystems.com.br> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xscripts/send-pull-request108
1 files changed, 21 insertions, 87 deletions
diff --git a/scripts/send-pull-request b/scripts/send-pull-request
index 76dd7a2d91..d265c474c0 100755
--- a/scripts/send-pull-request
+++ b/scripts/send-pull-request
@@ -1,15 +1,9 @@
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
9# Prevent environment leakage to these vars. 4# Prevent environment leakage to these vars.
10unset TO 5unset TO
11unset CC 6unset CC
12# allow the user to set FROM in the environment
13 7
14usage() 8usage()
15{ 9{
@@ -18,10 +12,6 @@ Usage: $(basename $0) [-h] [-a] [[-t email]...] -p pull-dir
18 -t email Explicitly add email to the recipients 12 -t email Explicitly add email to the recipients
19 -a Automatically harvest recipients from "*-by: email" lines 13 -a Automatically harvest recipients from "*-by: email" lines
20 in the patches in the pull-dir 14 in the patches in the pull-dir
21 -f Specify a FROM address, you can also use the FROM environment
22 variable. If you do not specify one, it will try to use the one
23 from your git config. This is ignored if -g is used.
24 -g Use git-send-email to send mail instead of sendmail
25 -p pull-dir Directory containing summary and patch files 15 -p pull-dir Directory containing summary and patch files
26EOM 16EOM
27} 17}
@@ -49,17 +39,11 @@ harvest_recipients()
49 39
50 40
51# Parse and verify arguments 41# Parse and verify arguments
52while getopts "af:ghp:t:" OPT; do 42while getopts "ahp:t:" OPT; do
53 case $OPT in 43 case $OPT in
54 a) 44 a)
55 AUTO=1 45 AUTO=1
56 ;; 46 ;;
57 f)
58 FROM="$OPTARG"
59 ;;
60 g)
61 PULL_MTA="git"
62 ;;
63 h) 47 h)
64 usage 48 usage
65 exit 0 49 exit 0
@@ -109,29 +93,14 @@ if [ $AUTO -eq 1 ]; then
109 harvest_recipients CC "^.*-[Bb][Yy]: *" 93 harvest_recipients CC "^.*-[Bb][Yy]: *"
110fi 94fi
111 95
112case "$PULL_MTA" in 96AUTO_TO="$(git config sendemail.to)"
113git) 97if [ -n "$AUTO_TO" ]; then
114 FROM="$(git config sendemail.from)" 98 if [ -n "$TO" ]; then
115 AUTO_TO="$(git config sendemail.to)" 99 TO="$TO,$AUTO_TO"
116 if [ -n "$AUTO_TO" ]; then 100 else
117 if [ -n "$TO" ]; then 101 TO="$AUTO_TO"
118 TO="$TO,$AUTO_TO"
119 else
120 TO="$AUTO_TO"
121 fi
122 fi 102 fi
123 ;; 103fi
124sendmail)
125 if [ -z "$FROM" ]; then
126 FROM="$(git config user.name) <$(git config user.email)>"
127 if [ -z "$FROM" ]; then
128 echo "ERROR: unable to determine a FROM address"
129 usage
130 exit 1
131 fi
132 fi
133 ;;
134esac
135 104
136if [ -z "$TO" ] && [ -z "$CC" ]; then 105if [ -z "$TO" ] && [ -z "$CC" ]; then
137 echo "ERROR: you have not specified any recipients." 106 echo "ERROR: you have not specified any recipients."
@@ -145,10 +114,7 @@ cat <<EOM
145The following patches: 114The following patches:
146$(for PATCH in $PDIR/*.patch; do echo " $PATCH"; done) 115$(for PATCH in $PDIR/*.patch; do echo " $PATCH"; done)
147 116
148will be sent with the following headers: 117will now be sent via the git send-email command.
149 From: $FROM
150 To: $TO
151 CC: $CC
152 118
153EOM 119EOM
154echo "Continue? [y/N] " 120echo "Continue? [y/N] "
@@ -156,52 +122,20 @@ read cont
156 122
157if [ "$cont" == "y" ] || [ "$cont" == "Y" ]; then 123if [ "$cont" == "y" ] || [ "$cont" == "Y" ]; then
158 ERROR=0 124 ERROR=0
159 case "$PULL_MTA" in 125 export IFS=$','
160 git) 126 GIT_TO=$(for R in $TO; do echo -n "--to='$R' "; done)
161 export IFS=$',' 127 GIT_CC=$(for R in $CC; do echo -n "--cc='$R' "; done)
162 GIT_TO=$(for R in $TO; do echo -n "--to='$R' "; done) 128 unset IFS
163 GIT_CC=$(for R in $CC; do echo -n "--cc='$R' "; done) 129 for PATCH in $PDIR/*patch; do
164 unset IFS 130 # We harvest the emails manually, so force git not to.
165 for PATCH in $PDIR/*patch; do 131 eval "git send-email $GIT_TO $GIT_CC --no-chain-reply-to --suppress-cc=all $PATCH"
166 # We harvest the emails manually, so force git not to. 132 if [ $? -eq 1 ]; then
167 eval "git send-email $GIT_TO $GIT_CC --no-chain-reply-to --suppress-cc=all $PATCH" 133 ERROR=1
168 if [ $? -eq 1 ]; then 134 fi
169 ERROR=1 135 done
170 fi
171 done
172 ;;
173 sendmail)
174 for PATCH in $PDIR/*patch; do
175 # Insert To and CC headers via formail to keep them separate and
176 # appending them to the sendmail command as -- $TO $CC has
177 # proven to be an exercise in futility.
178 #
179 # Clear the From header, leaving it up to sendmail to insert an
180 # appropriate one. Insert the original sender (per git) into the
181 # body of the message.
182 #
183 # Use tail to remove the email envelope from git or formail as
184 # msmtp (sendmail) would choke on them.
185 #
186 # Modify the patch date for sequential delivery, but retain the
187 # original date as "Old-Date".
188 DATE=$(date +"%a, %d %b %Y %k:%M:%S %z")
189 GIT_FROM=$(cat $PATCH | formail -X "From:")
190 cat $PATCH | formail -I "To: $TO" -I "CC: $CC" -I "From: $FROM" -i "Date: $DATE" | sed "0,/^$/s/^$/\n$GIT_FROM\n/" | tail -n +2 | sendmail -t
191 if [ $? -eq 1 ]; then
192 ERROR=1
193 fi
194 done
195 ;;
196 *)
197 echo "ERROR: unknown MTA: $PULL_MTA"
198 usage
199 exit 1
200 ;;
201 esac
202 136
203 if [ $ERROR -eq 1 ]; then 137 if [ $ERROR -eq 1 ]; then
204 echo "ERROR: Failed to send one or more messages. Check your MTA log for details." 138 echo "ERROR: Failed to send one or more messages."
205 fi 139 fi
206else 140else
207 echo "Send aborted." 141 echo "Send aborted."