summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/send-pull-request29
1 files changed, 26 insertions, 3 deletions
diff --git a/scripts/send-pull-request b/scripts/send-pull-request
index c08b3be..7f51a1b 100755
--- a/scripts/send-pull-request
+++ b/scripts/send-pull-request
@@ -9,6 +9,7 @@ fi
9# Prevent environment leakage to these vars. 9# Prevent environment leakage to these vars.
10unset TO 10unset TO
11unset CC 11unset CC
12# allow the user to set FROM in the environment
12 13
13usage() 14usage()
14{ 15{
@@ -17,6 +18,9 @@ Usage: $(basename $0) [-h] [-a] [[-t email]...] -p pull-dir
17 -t email Explicitly add email to the recipients 18 -t email Explicitly add email to the recipients
18 -a Automatically harvest recipients from "*-by: email" lines 19 -a Automatically harvest recipients from "*-by: email" lines
19 in the patches in the pull-dir 20 in the patches in the pull-dir
21 -f Specify a FROM address, you can also use the FROM environment
22 variable. If you do not specify one, it will try to use the one
23 from your git config. This is ignored if -g is used.
20 -g Use git-send-email to send mail instead of sendmail 24 -g Use git-send-email to send mail instead of sendmail
21 -p pull-dir Directory containing summary and patch files 25 -p pull-dir Directory containing summary and patch files
22EOM 26EOM
@@ -45,11 +49,14 @@ harvest_recipients()
45 49
46 50
47# Parse and verify arguments 51# Parse and verify arguments
48while getopts "aghp:t:" OPT; do 52while getopts "af:ghp:t:" OPT; do
49 case $OPT in 53 case $OPT in
50 a) 54 a)
51 AUTO=1 55 AUTO=1
52 ;; 56 ;;
57 f)
58 FROM="$OPTARG"
59 ;;
53 g) 60 g)
54 PULL_MTA="git" 61 PULL_MTA="git"
55 ;; 62 ;;
@@ -108,13 +115,29 @@ if [ -z "$TO" ] && [ -z "$CC" ]; then
108 exit 1 115 exit 1
109fi 116fi
110 117
118case "$PULL_MTA" in
119 git)
120 FROM="$(git config sendemail.from)"
121 ;;
122 sendmail)
123 if [ -z "$FROM" ]; then
124 FROM="$(git config user.name) <$(git config user.email)>"
125 if [ -z "$FROM" ]; then
126 echo "ERROR: unable to determine a FROM address"
127 usage
128 exit 1
129 fi
130 fi
131 ;;
132esac
111 133
112# Generate report for the user and require confirmation before sending 134# Generate report for the user and require confirmation before sending
113cat <<EOM 135cat <<EOM
114The following patches: 136The following patches:
115$(for PATCH in $PDIR/*.patch; do echo " $PATCH"; done) 137$(for PATCH in $PDIR/*.patch; do echo " $PATCH"; done)
116 138
117will be sent to the following recipients: 139will be sent with the following headers:
140 From: $FROM
118 To: $TO 141 To: $TO
119 CC: $CC 142 CC: $CC
120 143
@@ -155,7 +178,7 @@ if [ "$cont" == "y" ] || [ "$cont" == "Y" ]; then
155 # original date as "Old-Date". 178 # original date as "Old-Date".
156 DATE=$(date +"%a, %d %b %Y %k:%M:%S %z") 179 DATE=$(date +"%a, %d %b %Y %k:%M:%S %z")
157 GIT_FROM=$(cat $PATCH | formail -X "From:") 180 GIT_FROM=$(cat $PATCH | formail -X "From:")
158 cat $PATCH | formail -I "To: $TO" -I "CC: $CC" -I "From:" -i "Date: $DATE" | sed "0,/^$/s/^$/\n$GIT_FROM\n/" | tail -n +2 | sendmail -t 181 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
159 if [ $? -eq 1 ]; then 182 if [ $? -eq 1 ]; then
160 ERROR=1 183 ERROR=1
161 fi 184 fi