send-pull-request: allow users to select git-send-email or sendmail
cover send-pull-request: allow users to select git-send-email or sendmail
This message was sent using git-send-email from the modified script. See patch 1/1 for details.
Pull URL: git://git.pokylinux.org/poky-contrib.git
Branch: dvhart/git-pull
Browse: http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=dvhart/git-pull
Thanks,
Darren Hart <[email protected]>
---
Darren Hart (1):
send-pull-request: allow users to select git-send-email or sendmail
scripts/send-pull-request | 69 ++++++++++++++++++++++++++++++++------------ 1 files changed, 50 insertions(+), 19 deletions(-)
PATCH 1/1 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.
--- scripts/send-pull-request | 69 ++++++++++++++++++++++++++++++++------------ 1 files changed, 50 insertions(+), 19 deletions(-)
scripts/send-pull-request +50 -19
@@ -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."
Signature · 1 line
1.7.1