aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 03a78f9b1e3..9872c0dc658 100755
--- a/scripts/send-pull-request
+++ b/scripts/send-pull-request
@@ -1,6 +1,11 @@
#!/bin/bash
AUTO=0
+# Check env for any default settings, command line options will override these.
+if [ -z "$PULL_MTA" ]; then
+ PULL_MTA="sendmail"
+fi
+
usage()
{
cat <<EOM
@@ -8,6 +13,7 @@ Usage: $(basename $0) [-h] [-a] [[-t email]...] -p pull-dir
-t email Explicitly add email to the recipients
-a Automatically harvest recipients from "*-by: email" lines
in the patches in the pull-dir
+ -g Use git-send-email to send mail instead of sendmail
-p pull-dir Directory containing summary and patch files
EOM
}
@@ -35,11 +41,14 @@ harvest_recipients()
# Parse and verify arguments
-while getopts "ahp:t:" OPT; do
+while getopts "aghp:t:" OPT; do
case $OPT in
a)
AUTO=1
;;
+ g)
+ PULL_MTA="git"
+ ;;
h)
usage
exit 0
@@ -111,25 +120,47 @@ read cont
if [ "$cont" == "y" ] || [ "$cont" == "Y" ]; then
ERROR=0
- for PATCH in $PDIR/*patch; do
- # 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.
- #
- # Use tail to remove the email envelope from git or formail as
- # msmtp (sendmail) would choke on them.
- #
- # Modify the patch date for sequential delivery, but retain the
- # original date as "Old-Date".
- DATE=$(date +"%a, %d %b %Y %k:%M:%S %z")
- cat $PATCH | formail -I "To: $TO" -I "CC: $CC" -i "Date: $DATE" | tail -n +2 | sendmail -t
- if [ $? -eq 1 ]; then
- ERROR=1
- fi
- done
+ 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
+ # 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
+ ERROR=1
+ fi
+ done
+ ;;
+ sendmail)
+ for PATCH in $PDIR/*patch; do
+ # 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.
+ #
+ # Use tail to remove the email envelope from git or formail as
+ # msmtp (sendmail) would choke on them.
+ #
+ # Modify the patch date for sequential delivery, but retain the
+ # original date as "Old-Date".
+ DATE=$(date +"%a, %d %b %Y %k:%M:%S %z")
+ cat $PATCH | formail -I "To: $TO" -I "CC: $CC" -i "Date: $DATE" | tail -n +2 | sendmail -t
+ if [ $? -eq 1 ]; then
+ ERROR=1
+ fi
+ done
+ ;;
+ *)
+ echo "ERROR: unknown MTA: $PULL_MTA"
+ usage
+ exit 1
+ ;;
+ esac
+
if [ $ERROR -eq 1 ]; then
- echo "ERROR: sendmail failed to send one or more messages. Check your"
- echo " sendmail log for details."
+ echo "ERROR: Failed to send one or more messages. Check your MTA log for details."
fi
else
echo "Send aborted."