diff options
Diffstat (limited to 'scripts/send-pull-request')
| -rwxr-xr-x | scripts/send-pull-request | 69 |
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 |
| 2 | AUTO=0 | 2 | AUTO=0 |
| 3 | 3 | ||
| 4 | # Check env for any default settings, command line options will override these. | ||
| 5 | if [ -z "$PULL_MTA" ]; then | ||
| 6 | PULL_MTA="sendmail" | ||
| 7 | fi | ||
| 8 | |||
| 4 | usage() | 9 | usage() |
| 5 | { | 10 | { |
| 6 | cat <<EOM | 11 | cat <<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 |
| 12 | EOM | 18 | EOM |
| 13 | } | 19 | } |
| @@ -35,11 +41,14 @@ harvest_recipients() | |||
| 35 | 41 | ||
| 36 | 42 | ||
| 37 | # Parse and verify arguments | 43 | # Parse and verify arguments |
| 38 | while getopts "ahp:t:" OPT; do | 44 | while 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 | ||
| 112 | if [ "$cont" == "y" ] || [ "$cont" == "Y" ]; then | 121 | if [ "$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 |
| 134 | else | 165 | else |
| 135 | echo "Send aborted." | 166 | echo "Send aborted." |
