diff options
| -rwxr-xr-x | scripts/send-pull-request | 68 |
1 files changed, 26 insertions, 42 deletions
diff --git a/scripts/send-pull-request b/scripts/send-pull-request index 21eb302169..8d0bd343ee 100755 --- a/scripts/send-pull-request +++ b/scripts/send-pull-request | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | #!/bin/bash | 1 | #!/bin/bash |
| 2 | AUTO=0 | 2 | AUTO=0 |
| 3 | AUTO_CL=0 | 3 | AUTO_CL=0 |
| 4 | GITSOBCC="" | ||
| 4 | 5 | ||
| 5 | # Prevent environment leakage to these vars. | 6 | # Prevent environment leakage to these vars. |
| 6 | unset TO | 7 | unset TO |
| @@ -59,10 +60,11 @@ while getopts "achp:t:" OPT; do | |||
| 59 | case $OPT in | 60 | case $OPT in |
| 60 | a) | 61 | a) |
| 61 | AUTO_CL=1 | 62 | AUTO_CL=1 |
| 62 | AUTO=1 | 63 | # Fall through to include -c |
| 63 | ;; | 64 | ;& |
| 64 | c) | 65 | c) |
| 65 | AUTO=1 | 66 | AUTO=1 |
| 67 | GITSOBCC="--signed-off-by-cc" | ||
| 66 | ;; | 68 | ;; |
| 67 | h) | 69 | h) |
| 68 | usage | 70 | usage |
| @@ -130,48 +132,30 @@ if [ -z "$TO" ] && [ -z "$AUTO_CC" ]; then | |||
| 130 | fi | 132 | fi |
| 131 | 133 | ||
| 132 | 134 | ||
| 133 | # Generate report for the user and require confirmation before sending | 135 | # Convert the collected addresses into git-send-email argument strings |
| 134 | cat <<EOM | 136 | export IFS=$',' |
| 135 | The following patches: | 137 | GIT_TO=$(for R in $TO; do echo -n "--to='$R' "; done) |
| 136 | $(for PATCH in $PDIR/*.patch; do echo " $PATCH"; done) | 138 | GIT_CC=$(for R in $AUTO_CC; do echo -n "--cc='$R' "; done) |
| 139 | unset IFS | ||
| 137 | 140 | ||
| 138 | will now be sent via the git send-email command. Git will prompt you before | ||
| 139 | sending any email. | ||
| 140 | 141 | ||
| 141 | EOM | 142 | # Handoff to git-send-email. It will perform the send confirmation. |
| 142 | echo "Continue? [y/N] " | 143 | PATCHES=$(echo $PDIR/*.patch) |
| 143 | read cont | 144 | if [ $AUTO_CL -eq 1 ]; then |
| 144 | 145 | # Send the cover letter to every recipient, both specified as well as | |
| 145 | if [ "$cont" == "y" ] || [ "$cont" == "Y" ]; then | 146 | # harvested. Then remove it from the patches list. |
| 146 | ERROR=0 | 147 | eval "git send-email $GIT_TO $GIT_CC --confirm=always --no-chain-reply-to --suppress-cc=all $CL" |
| 147 | export IFS=$',' | 148 | if [ $? -eq 1 ]; then |
| 148 | GIT_TO=$(for R in $TO; do echo -n "--to='$R' "; done) | 149 | echo "ERROR: failed to send cover-letter with automatic recipients." |
| 149 | GIT_CC=$(for R in $AUTO_CC; do echo -n "--cc='$R' "; done) | 150 | exit 1 |
| 150 | unset IFS | ||
| 151 | for PATCH in $PDIR/*patch; do | ||
| 152 | if [ $AUTO -eq 1 ]; then | ||
| 153 | if [ $PATCH == "$CL" ] && [ $AUTO_CL -eq 1 ]; then | ||
| 154 | # Send the cover letter to every recipient, both | ||
| 155 | # specified as well as harvested. | ||
| 156 | eval "git send-email $GIT_TO $GIT_CC --confirm=always --no-chain-reply-to --suppress-cc=all $PATCH" | ||
| 157 | else | ||
| 158 | # Send the patch to the specified recipients and | ||
| 159 | # those git finds in this specific patch. | ||
| 160 | eval "git send-email $GIT_TO --confirm=always --no-chain-reply-to --signed-off-by-cc $PATCH" | ||
| 161 | fi | ||
| 162 | else | ||
| 163 | # Only send to the explicitly specified recipients | ||
| 164 | eval "git send-email $GIT_TO --confirm=always --no-chain-reply-to --suppress-cc=all $PATCH" | ||
| 165 | fi | ||
| 166 | if [ $? -eq 1 ]; then | ||
| 167 | ERROR=1 | ||
| 168 | fi | ||
| 169 | done | ||
| 170 | |||
| 171 | if [ $ERROR -eq 1 ]; then | ||
| 172 | echo "ERROR: Failed to send one or more messages." | ||
| 173 | fi | 151 | fi |
| 174 | else | 152 | PATCHES=${PATCHES/"$CL"/} |
| 175 | echo "Send aborted." | ||
| 176 | fi | 153 | fi |
| 177 | 154 | ||
| 155 | # Send the patch to the specified recipients and, if -c was specified, those git | ||
| 156 | # finds in this specific patch. | ||
| 157 | eval "git send-email $GIT_TO --confirm=always --no-chain-reply-to $GITSOBCC $PATCHES" | ||
| 158 | if [ $? -eq 1 ]; then | ||
| 159 | echo "ERROR: failed to send patches." | ||
| 160 | exit 1 | ||
| 161 | fi | ||
