diff options
| author | Tudor Florea <tudor.florea@enea.com> | 2015-10-09 22:59:03 +0200 |
|---|---|---|
| committer | Tudor Florea <tudor.florea@enea.com> | 2015-10-09 22:59:03 +0200 |
| commit | 972dcfcdbfe75dcfeb777150c136576cf1a71e99 (patch) | |
| tree | 97a61cd7e293d7ae9d56ef7ed0f81253365bb026 /scripts/send-pull-request | |
| download | poky-972dcfcdbfe75dcfeb777150c136576cf1a71e99.tar.gz | |
initial commit for Enea Linux 5.0 arm
Signed-off-by: Tudor Florea <tudor.florea@enea.com>
Diffstat (limited to 'scripts/send-pull-request')
| -rwxr-xr-x | scripts/send-pull-request | 179 |
1 files changed, 179 insertions, 0 deletions
diff --git a/scripts/send-pull-request b/scripts/send-pull-request new file mode 100755 index 0000000000..575549db38 --- /dev/null +++ b/scripts/send-pull-request | |||
| @@ -0,0 +1,179 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # | ||
| 3 | # Copyright (c) 2010-2011, Intel Corporation. | ||
| 4 | # All Rights Reserved | ||
| 5 | # | ||
| 6 | # This program is free software; you can redistribute it and/or modify | ||
| 7 | # it under the terms of the GNU General Public License as published by | ||
| 8 | # the Free Software Foundation; either version 2 of the License, or | ||
| 9 | # (at your option) any later version. | ||
| 10 | # | ||
| 11 | # This program is distributed in the hope that it will be useful, | ||
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See | ||
| 14 | # the GNU General Public License for more details. | ||
| 15 | # | ||
| 16 | # You should have received a copy of the GNU General Public License | ||
| 17 | # along with this program; if not, write to the Free Software | ||
| 18 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 19 | # | ||
| 20 | |||
| 21 | # | ||
| 22 | # This script is intended to be used to send a patch series prepared by the | ||
| 23 | # create-pull-request script to Open Embedded and The Yocto Project, as well | ||
| 24 | # as to related projects and layers. | ||
| 25 | # | ||
| 26 | |||
| 27 | AUTO=0 | ||
| 28 | AUTO_CL=0 | ||
| 29 | GITSOBCC="--suppress-cc=all" | ||
| 30 | |||
| 31 | # Prevent environment leakage to these vars. | ||
| 32 | unset TO | ||
| 33 | unset CC | ||
| 34 | unset AUTO_CC | ||
| 35 | unset EXTRA_CC | ||
| 36 | |||
| 37 | usage() | ||
| 38 | { | ||
| 39 | cat <<EOM | ||
| 40 | Usage: $(basename $0) [-h] [-a] [-c] [[-t email]...] -p pull-dir | ||
| 41 | -a Send the cover letter to every recipient listed in Cc and | ||
| 42 | Signed-off-by lines found in the cover letter and the patches. | ||
| 43 | This option implies -c. | ||
| 44 | -c Expand the Cc list for the individual patches using the Cc and | ||
| 45 | Signed-off-by lines from the same patch. | ||
| 46 | -C Add extra CC to each email sent. | ||
| 47 | -p pull-dir Directory containing summary and patch files | ||
| 48 | -t email Explicitly add email to the recipients | ||
| 49 | EOM | ||
| 50 | } | ||
| 51 | |||
| 52 | # Collect addresses from a patch into AUTO_CC | ||
| 53 | # $1: a patch file | ||
| 54 | harvest_recipients() | ||
| 55 | { | ||
| 56 | PATCH=$1 | ||
| 57 | export IFS=$',\n' | ||
| 58 | for REGX in "^[Cc][Cc]: *" "^[Ss]igned-[Oo]ff-[Bb]y: *"; do | ||
| 59 | for EMAIL in $(sed '/^---$/q' $PATCH | grep -e "$REGX" | sed "s/$REGX//"); do | ||
| 60 | if [ "${AUTO_CC/$EMAIL/}" == "$AUTO_CC" ] && [ -n "$EMAIL" ]; then | ||
| 61 | if [ -z "$AUTO_CC" ]; then | ||
| 62 | AUTO_CC=$EMAIL; | ||
| 63 | else | ||
| 64 | AUTO_CC="$AUTO_CC,$EMAIL"; | ||
| 65 | fi | ||
| 66 | fi | ||
| 67 | done | ||
| 68 | done | ||
| 69 | unset IFS | ||
| 70 | } | ||
| 71 | |||
| 72 | # Parse and verify arguments | ||
| 73 | while getopts "acC:hp:t:" OPT; do | ||
| 74 | case $OPT in | ||
| 75 | a) | ||
| 76 | AUTO=1 | ||
| 77 | GITSOBCC="--signed-off-by-cc" | ||
| 78 | AUTO_CL=1 | ||
| 79 | ;; | ||
| 80 | c) | ||
| 81 | AUTO=1 | ||
| 82 | GITSOBCC="--signed-off-by-cc" | ||
| 83 | ;; | ||
| 84 | C) | ||
| 85 | EXTRA_CC="$OPTARG" | ||
| 86 | ;; | ||
| 87 | h) | ||
| 88 | usage | ||
| 89 | exit 0 | ||
| 90 | ;; | ||
| 91 | p) | ||
| 92 | PDIR=${OPTARG%/} | ||
| 93 | if [ ! -d $PDIR ]; then | ||
| 94 | echo "ERROR: pull-dir \"$PDIR\" does not exist." | ||
| 95 | usage | ||
| 96 | exit 1 | ||
| 97 | fi | ||
| 98 | ;; | ||
| 99 | t) | ||
| 100 | if [ -n "$TO" ]; then | ||
| 101 | TO="$TO,$OPTARG" | ||
| 102 | else | ||
| 103 | TO="$OPTARG" | ||
| 104 | fi | ||
| 105 | ;; | ||
| 106 | esac | ||
| 107 | done | ||
| 108 | |||
| 109 | if [ -z "$PDIR" ]; then | ||
| 110 | echo "ERROR: you must specify a pull-dir." | ||
| 111 | usage | ||
| 112 | exit 1 | ||
| 113 | fi | ||
| 114 | |||
| 115 | |||
| 116 | # Verify the cover letter is complete and free of tokens | ||
| 117 | if [ -e $PDIR/0000-cover-letter.patch ]; then | ||
| 118 | CL="$PDIR/0000-cover-letter.patch" | ||
| 119 | for TOKEN in SUBJECT BLURB; do | ||
| 120 | grep -q "*** $TOKEN HERE ***" "$CL" | ||
| 121 | if [ $? -eq 0 ]; then | ||
| 122 | echo "ERROR: Please edit $CL and try again (Look for '*** $TOKEN HERE ***')." | ||
| 123 | exit 1 | ||
| 124 | fi | ||
| 125 | done | ||
| 126 | else | ||
| 127 | echo "WARNING: No cover letter will be sent." | ||
| 128 | fi | ||
| 129 | |||
| 130 | # Harvest emails from the generated patches and populate AUTO_CC. | ||
| 131 | if [ $AUTO_CL -eq 1 ]; then | ||
| 132 | for PATCH in $PDIR/*.patch; do | ||
| 133 | harvest_recipients $PATCH | ||
| 134 | done | ||
| 135 | fi | ||
| 136 | |||
| 137 | AUTO_TO="$(git config sendemail.to)" | ||
| 138 | if [ -n "$AUTO_TO" ]; then | ||
| 139 | if [ -n "$TO" ]; then | ||
| 140 | TO="$TO,$AUTO_TO" | ||
| 141 | else | ||
| 142 | TO="$AUTO_TO" | ||
| 143 | fi | ||
| 144 | fi | ||
| 145 | |||
| 146 | if [ -z "$TO" ] && [ -z "$AUTO_CC" ]; then | ||
| 147 | echo "ERROR: you have not specified any recipients." | ||
| 148 | usage | ||
| 149 | exit 1 | ||
| 150 | fi | ||
| 151 | |||
| 152 | |||
| 153 | # Convert the collected addresses into git-send-email argument strings | ||
| 154 | export IFS=$',' | ||
| 155 | GIT_TO=$(for R in $TO; do echo -n "--to='$R' "; done) | ||
| 156 | GIT_CC=$(for R in $AUTO_CC; do echo -n "--cc='$R' "; done) | ||
| 157 | GIT_EXTRA_CC=$(for R in $EXTRA_CC; do echo -n "--cc='$R' "; done) | ||
| 158 | unset IFS | ||
| 159 | |||
| 160 | # Handoff to git-send-email. It will perform the send confirmation. | ||
| 161 | PATCHES=$(echo $PDIR/*.patch) | ||
| 162 | if [ $AUTO_CL -eq 1 ]; then | ||
| 163 | # Send the cover letter to every recipient, both specified as well as | ||
| 164 | # harvested. Then remove it from the patches list. | ||
| 165 | eval "git send-email $GIT_TO $GIT_CC $GIT_EXTRA_CC --confirm=always --no-chain-reply-to --suppress-cc=all $CL" | ||
| 166 | if [ $? -eq 1 ]; then | ||
| 167 | echo "ERROR: failed to send cover-letter with automatic recipients." | ||
| 168 | exit 1 | ||
| 169 | fi | ||
| 170 | PATCHES=${PATCHES/"$CL"/} | ||
| 171 | fi | ||
| 172 | |||
| 173 | # Send the patch to the specified recipients and, if -c was specified, those git | ||
| 174 | # finds in this specific patch. | ||
| 175 | eval "git send-email $GIT_TO $GIT_EXTRA_CC --confirm=always --no-chain-reply-to $GITSOBCC $PATCHES" | ||
| 176 | if [ $? -eq 1 ]; then | ||
| 177 | echo "ERROR: failed to send patches." | ||
| 178 | exit 1 | ||
| 179 | fi | ||
