summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/send-pull-request250
1 files changed, 125 insertions, 125 deletions
diff --git a/scripts/send-pull-request b/scripts/send-pull-request
index 3af2a9fa7e..76dd7a2d91 100755
--- a/scripts/send-pull-request
+++ b/scripts/send-pull-request
@@ -31,72 +31,72 @@ EOM
31# $2: The regex to match and strip from the line with email addresses 31# $2: The regex to match and strip from the line with email addresses
32harvest_recipients() 32harvest_recipients()
33{ 33{
34 TO_CC=$1 34 TO_CC=$1
35 REGX=$2 35 REGX=$2
36 export IFS=$',\n' 36 export IFS=$',\n'
37 for PATCH in $PDIR/*.patch; do 37 for PATCH in $PDIR/*.patch; do
38 # Grab To addresses 38 # Grab To addresses
39 for EMAIL in $(sed '/^---$/q' $PATCH | grep -e "$REGX" | sed "s/$REGX//"); do 39 for EMAIL in $(sed '/^---$/q' $PATCH | grep -e "$REGX" | sed "s/$REGX//"); do
40 if [ "$TO_CC" == "TO" ] && [ "${TO/$EMAIL/}" == "$TO" ] && [ -n "$EMAIL" ]; then 40 if [ "$TO_CC" == "TO" ] && [ "${TO/$EMAIL/}" == "$TO" ] && [ -n "$EMAIL" ]; then
41 if [ -z "$TO" ]; then TO=$EMAIL; else TO="$TO,$EMAIL"; fi 41 if [ -z "$TO" ]; then TO=$EMAIL; else TO="$TO,$EMAIL"; fi
42 elif [ "$TO_CC" == "CC" ] && [ "${CC/$EMAIL/}" == "$CC" ] && [ -n "$EMAIL" ]; then 42 elif [ "$TO_CC" == "CC" ] && [ "${CC/$EMAIL/}" == "$CC" ] && [ -n "$EMAIL" ]; then
43 if [ -z "$CC" ]; then CC=$EMAIL; else CC="$CC,$EMAIL"; fi 43 if [ -z "$CC" ]; then CC=$EMAIL; else CC="$CC,$EMAIL"; fi
44 fi 44 fi
45 done 45 done
46 done 46 done
47 unset IFS 47 unset IFS
48} 48}
49 49
50 50
51# Parse and verify arguments 51# Parse and verify arguments
52while getopts "af:ghp:t:" OPT; do 52while getopts "af:ghp:t:" OPT; do
53 case $OPT in 53 case $OPT in
54 a) 54 a)
55 AUTO=1 55 AUTO=1
56 ;; 56 ;;
57 f) 57 f)
58 FROM="$OPTARG" 58 FROM="$OPTARG"
59 ;; 59 ;;
60 g) 60 g)
61 PULL_MTA="git" 61 PULL_MTA="git"
62 ;; 62 ;;
63 h) 63 h)
64 usage 64 usage
65 exit 0 65 exit 0
66 ;; 66 ;;
67 p) 67 p)
68 PDIR=${OPTARG%/} 68 PDIR=${OPTARG%/}
69 if [ ! -d $PDIR ]; then 69 if [ ! -d $PDIR ]; then
70 echo "ERROR: pull-dir \"$PDIR\" does not exist." 70 echo "ERROR: pull-dir \"$PDIR\" does not exist."
71 usage 71 usage
72 exit 1 72 exit 1
73 fi 73 fi
74 ;; 74 ;;
75 t) 75 t)
76 if [ -n "$TO" ]; then 76 if [ -n "$TO" ]; then
77 TO="$TO,$OPTARG" 77 TO="$TO,$OPTARG"
78 else 78 else
79 TO="$OPTARG" 79 TO="$OPTARG"
80 fi 80 fi
81 ;; 81 ;;
82 esac 82 esac
83done 83done
84 84
85if [ -z "$PDIR" ]; then 85if [ -z "$PDIR" ]; then
86 echo "ERROR: you must specify a pull-dir." 86 echo "ERROR: you must specify a pull-dir."
87 usage 87 usage
88 exit 1 88 exit 1
89fi 89fi
90 90
91 91
92# Verify the cover letter is complete and free of tokens 92# Verify the cover letter is complete and free of tokens
93CL="$PDIR/0000-cover-letter.patch" 93CL="$PDIR/0000-cover-letter.patch"
94for TOKEN in SUBJECT BLURB; do 94for TOKEN in SUBJECT BLURB; do
95 grep -q "*** $TOKEN HERE ***" "$CL" 95 grep -q "*** $TOKEN HERE ***" "$CL"
96 if [ $? -eq 0 ]; then 96 if [ $? -eq 0 ]; then
97 echo "ERROR: Please edit $CL and try again (Look for '*** $TOKEN HERE ***')." 97 echo "ERROR: Please edit $CL and try again (Look for '*** $TOKEN HERE ***')."
98 exit 1 98 exit 1
99 fi 99 fi
100done 100done
101 101
102 102
@@ -104,39 +104,39 @@ done
104# In addition to To and CC headers/lines, the common Signed-off-by, Tested-by, 104# In addition to To and CC headers/lines, the common Signed-off-by, Tested-by,
105# etc. (*-by) will be added to CC. 105# etc. (*-by) will be added to CC.
106if [ $AUTO -eq 1 ]; then 106if [ $AUTO -eq 1 ]; then
107 harvest_recipients TO "^[Tt][Oo]: *" 107 harvest_recipients TO "^[Tt][Oo]: *"
108 harvest_recipients CC "^[Cc][Cc]: *" 108 harvest_recipients CC "^[Cc][Cc]: *"
109 harvest_recipients CC "^.*-[Bb][Yy]: *" 109 harvest_recipients CC "^.*-[Bb][Yy]: *"
110fi 110fi
111 111
112case "$PULL_MTA" in 112case "$PULL_MTA" in
113 git) 113git)
114 FROM="$(git config sendemail.from)" 114 FROM="$(git config sendemail.from)"
115 AUTO_TO="$(git config sendemail.to)" 115 AUTO_TO="$(git config sendemail.to)"
116 if [ -n "$AUTO_TO" ]; then 116 if [ -n "$AUTO_TO" ]; then
117 if [ -n "$TO" ]; then 117 if [ -n "$TO" ]; then
118 TO="$TO,$AUTO_TO" 118 TO="$TO,$AUTO_TO"
119 else 119 else
120 TO="$AUTO_TO" 120 TO="$AUTO_TO"
121 fi 121 fi
122 fi
123 ;;
124sendmail)
125 if [ -z "$FROM" ]; then
126 FROM="$(git config user.name) <$(git config user.email)>"
127 if [ -z "$FROM" ]; then
128 echo "ERROR: unable to determine a FROM address"
129 usage
130 exit 1
131 fi
122 fi 132 fi
123 ;; 133 ;;
124 sendmail)
125 if [ -z "$FROM" ]; then
126 FROM="$(git config user.name) <$(git config user.email)>"
127 if [ -z "$FROM" ]; then
128 echo "ERROR: unable to determine a FROM address"
129 usage
130 exit 1
131 fi
132 fi
133 ;;
134esac 134esac
135 135
136if [ -z "$TO" ] && [ -z "$CC" ]; then 136if [ -z "$TO" ] && [ -z "$CC" ]; then
137 echo "ERROR: you have not specified any recipients." 137 echo "ERROR: you have not specified any recipients."
138 usage 138 usage
139 exit 1 139 exit 1
140fi 140fi
141 141
142 142
@@ -155,55 +155,55 @@ echo "Continue? [y/N] "
155read cont 155read cont
156 156
157if [ "$cont" == "y" ] || [ "$cont" == "Y" ]; then 157if [ "$cont" == "y" ] || [ "$cont" == "Y" ]; then
158 ERROR=0 158 ERROR=0
159 case "$PULL_MTA" in 159 case "$PULL_MTA" in
160 git) 160 git)
161 export IFS=$',' 161 export IFS=$','
162 GIT_TO=$(for R in $TO; do echo -n "--to='$R' "; done) 162 GIT_TO=$(for R in $TO; do echo -n "--to='$R' "; done)
163 GIT_CC=$(for R in $CC; do echo -n "--cc='$R' "; done) 163 GIT_CC=$(for R in $CC; do echo -n "--cc='$R' "; done)
164 unset IFS 164 unset IFS
165 for PATCH in $PDIR/*patch; do 165 for PATCH in $PDIR/*patch; do
166 # We harvest the emails manually, so force git not to. 166 # We harvest the emails manually, so force git not to.
167 eval "git send-email $GIT_TO $GIT_CC --no-chain-reply-to --suppress-cc=all $PATCH" 167 eval "git send-email $GIT_TO $GIT_CC --no-chain-reply-to --suppress-cc=all $PATCH"
168 if [ $? -eq 1 ]; then 168 if [ $? -eq 1 ]; then
169 ERROR=1 169 ERROR=1
170 fi 170 fi
171 done 171 done
172 ;; 172 ;;
173 sendmail) 173 sendmail)
174 for PATCH in $PDIR/*patch; do 174 for PATCH in $PDIR/*patch; do
175 # Insert To and CC headers via formail to keep them separate and 175 # Insert To and CC headers via formail to keep them separate and
176 # appending them to the sendmail command as -- $TO $CC has 176 # appending them to the sendmail command as -- $TO $CC has
177 # proven to be an exercise in futility. 177 # proven to be an exercise in futility.
178 # 178 #
179 # Clear the From header, leaving it up to sendmail to insert an 179 # Clear the From header, leaving it up to sendmail to insert an
180 # appropriate one. Insert the original sender (per git) into the 180 # appropriate one. Insert the original sender (per git) into the
181 # body of the message. 181 # body of the message.
182 # 182 #
183 # Use tail to remove the email envelope from git or formail as 183 # Use tail to remove the email envelope from git or formail as
184 # msmtp (sendmail) would choke on them. 184 # msmtp (sendmail) would choke on them.
185 # 185 #
186 # Modify the patch date for sequential delivery, but retain the 186 # Modify the patch date for sequential delivery, but retain the
187 # original date as "Old-Date". 187 # original date as "Old-Date".
188 DATE=$(date +"%a, %d %b %Y %k:%M:%S %z") 188 DATE=$(date +"%a, %d %b %Y %k:%M:%S %z")
189 GIT_FROM=$(cat $PATCH | formail -X "From:") 189 GIT_FROM=$(cat $PATCH | formail -X "From:")
190 cat $PATCH | formail -I "To: $TO" -I "CC: $CC" -I "From: $FROM" -i "Date: $DATE" | sed "0,/^$/s/^$/\n$GIT_FROM\n/" | tail -n +2 | sendmail -t 190 cat $PATCH | formail -I "To: $TO" -I "CC: $CC" -I "From: $FROM" -i "Date: $DATE" | sed "0,/^$/s/^$/\n$GIT_FROM\n/" | tail -n +2 | sendmail -t
191 if [ $? -eq 1 ]; then 191 if [ $? -eq 1 ]; then
192 ERROR=1 192 ERROR=1
193 fi 193 fi
194 done 194 done
195 ;; 195 ;;
196 *) 196 *)
197 echo "ERROR: unknown MTA: $PULL_MTA" 197 echo "ERROR: unknown MTA: $PULL_MTA"
198 usage 198 usage
199 exit 1 199 exit 1
200 ;; 200 ;;
201 esac 201 esac
202 202
203 if [ $ERROR -eq 1 ]; then 203 if [ $ERROR -eq 1 ]; then
204 echo "ERROR: Failed to send one or more messages. Check your MTA log for details." 204 echo "ERROR: Failed to send one or more messages. Check your MTA log for details."
205 fi 205 fi
206else 206else
207 echo "Send aborted." 207 echo "Send aborted."
208fi 208fi
209 209