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)
downloadopenembedded-core-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 @@
#!/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."