send-pull-request: whitespace cleanup
Indent with tabs, not spaces, for consistency with other bash scripts. (From OE-Core rev: 187217ec380e89d81a53d9fd5f007d8f95356029) Signed-off-by: Darren Hart <dvhart@linux.intel.com> Acked-by: Otavio Salvador <otavio@ossystems.com.br> Cc: Otavio Salvador <otavio@ossystems.com.br> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
dca0c48465
commit
b158757ef9
|
@ -31,72 +31,72 @@ EOM
|
||||||
# $2: The regex to match and strip from the line with email addresses
|
# $2: The regex to match and strip from the line with email addresses
|
||||||
harvest_recipients()
|
harvest_recipients()
|
||||||
{
|
{
|
||||||
TO_CC=$1
|
TO_CC=$1
|
||||||
REGX=$2
|
REGX=$2
|
||||||
export IFS=$',\n'
|
export IFS=$',\n'
|
||||||
for PATCH in $PDIR/*.patch; do
|
for PATCH in $PDIR/*.patch; do
|
||||||
# Grab To addresses
|
# Grab To addresses
|
||||||
for EMAIL in $(sed '/^---$/q' $PATCH | grep -e "$REGX" | sed "s/$REGX//"); do
|
for EMAIL in $(sed '/^---$/q' $PATCH | grep -e "$REGX" | sed "s/$REGX//"); do
|
||||||
if [ "$TO_CC" == "TO" ] && [ "${TO/$EMAIL/}" == "$TO" ] && [ -n "$EMAIL" ]; then
|
if [ "$TO_CC" == "TO" ] && [ "${TO/$EMAIL/}" == "$TO" ] && [ -n "$EMAIL" ]; then
|
||||||
if [ -z "$TO" ]; then TO=$EMAIL; else TO="$TO,$EMAIL"; fi
|
if [ -z "$TO" ]; then TO=$EMAIL; else TO="$TO,$EMAIL"; fi
|
||||||
elif [ "$TO_CC" == "CC" ] && [ "${CC/$EMAIL/}" == "$CC" ] && [ -n "$EMAIL" ]; then
|
elif [ "$TO_CC" == "CC" ] && [ "${CC/$EMAIL/}" == "$CC" ] && [ -n "$EMAIL" ]; then
|
||||||
if [ -z "$CC" ]; then CC=$EMAIL; else CC="$CC,$EMAIL"; fi
|
if [ -z "$CC" ]; then CC=$EMAIL; else CC="$CC,$EMAIL"; fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
unset IFS
|
unset IFS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Parse and verify arguments
|
# Parse and verify arguments
|
||||||
while getopts "af:ghp:t:" OPT; do
|
while getopts "af:ghp:t:" OPT; do
|
||||||
case $OPT in
|
case $OPT in
|
||||||
a)
|
a)
|
||||||
AUTO=1
|
AUTO=1
|
||||||
;;
|
;;
|
||||||
f)
|
f)
|
||||||
FROM="$OPTARG"
|
FROM="$OPTARG"
|
||||||
;;
|
;;
|
||||||
g)
|
g)
|
||||||
PULL_MTA="git"
|
PULL_MTA="git"
|
||||||
;;
|
;;
|
||||||
h)
|
h)
|
||||||
usage
|
usage
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
p)
|
p)
|
||||||
PDIR=${OPTARG%/}
|
PDIR=${OPTARG%/}
|
||||||
if [ ! -d $PDIR ]; then
|
if [ ! -d $PDIR ]; then
|
||||||
echo "ERROR: pull-dir \"$PDIR\" does not exist."
|
echo "ERROR: pull-dir \"$PDIR\" does not exist."
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
t)
|
t)
|
||||||
if [ -n "$TO" ]; then
|
if [ -n "$TO" ]; then
|
||||||
TO="$TO,$OPTARG"
|
TO="$TO,$OPTARG"
|
||||||
else
|
else
|
||||||
TO="$OPTARG"
|
TO="$OPTARG"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -z "$PDIR" ]; then
|
if [ -z "$PDIR" ]; then
|
||||||
echo "ERROR: you must specify a pull-dir."
|
echo "ERROR: you must specify a pull-dir."
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Verify the cover letter is complete and free of tokens
|
# Verify the cover letter is complete and free of tokens
|
||||||
CL="$PDIR/0000-cover-letter.patch"
|
CL="$PDIR/0000-cover-letter.patch"
|
||||||
for TOKEN in SUBJECT BLURB; do
|
for TOKEN in SUBJECT BLURB; do
|
||||||
grep -q "*** $TOKEN HERE ***" "$CL"
|
grep -q "*** $TOKEN HERE ***" "$CL"
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
echo "ERROR: Please edit $CL and try again (Look for '*** $TOKEN HERE ***')."
|
echo "ERROR: Please edit $CL and try again (Look for '*** $TOKEN HERE ***')."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
@ -104,39 +104,39 @@ done
|
||||||
# In addition to To and CC headers/lines, the common Signed-off-by, Tested-by,
|
# In addition to To and CC headers/lines, the common Signed-off-by, Tested-by,
|
||||||
# etc. (*-by) will be added to CC.
|
# etc. (*-by) will be added to CC.
|
||||||
if [ $AUTO -eq 1 ]; then
|
if [ $AUTO -eq 1 ]; then
|
||||||
harvest_recipients TO "^[Tt][Oo]: *"
|
harvest_recipients TO "^[Tt][Oo]: *"
|
||||||
harvest_recipients CC "^[Cc][Cc]: *"
|
harvest_recipients CC "^[Cc][Cc]: *"
|
||||||
harvest_recipients CC "^.*-[Bb][Yy]: *"
|
harvest_recipients CC "^.*-[Bb][Yy]: *"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "$PULL_MTA" in
|
case "$PULL_MTA" in
|
||||||
git)
|
git)
|
||||||
FROM="$(git config sendemail.from)"
|
FROM="$(git config sendemail.from)"
|
||||||
AUTO_TO="$(git config sendemail.to)"
|
AUTO_TO="$(git config sendemail.to)"
|
||||||
if [ -n "$AUTO_TO" ]; then
|
if [ -n "$AUTO_TO" ]; then
|
||||||
if [ -n "$TO" ]; then
|
if [ -n "$TO" ]; then
|
||||||
TO="$TO,$AUTO_TO"
|
TO="$TO,$AUTO_TO"
|
||||||
else
|
else
|
||||||
TO="$AUTO_TO"
|
TO="$AUTO_TO"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
sendmail)
|
sendmail)
|
||||||
if [ -z "$FROM" ]; then
|
if [ -z "$FROM" ]; then
|
||||||
FROM="$(git config user.name) <$(git config user.email)>"
|
FROM="$(git config user.name) <$(git config user.email)>"
|
||||||
if [ -z "$FROM" ]; then
|
if [ -z "$FROM" ]; then
|
||||||
echo "ERROR: unable to determine a FROM address"
|
echo "ERROR: unable to determine a FROM address"
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ -z "$TO" ] && [ -z "$CC" ]; then
|
if [ -z "$TO" ] && [ -z "$CC" ]; then
|
||||||
echo "ERROR: you have not specified any recipients."
|
echo "ERROR: you have not specified any recipients."
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
@ -155,55 +155,55 @@ echo "Continue? [y/N] "
|
||||||
read cont
|
read cont
|
||||||
|
|
||||||
if [ "$cont" == "y" ] || [ "$cont" == "Y" ]; then
|
if [ "$cont" == "y" ] || [ "$cont" == "Y" ]; then
|
||||||
ERROR=0
|
ERROR=0
|
||||||
case "$PULL_MTA" in
|
case "$PULL_MTA" in
|
||||||
git)
|
git)
|
||||||
export IFS=$','
|
export IFS=$','
|
||||||
GIT_TO=$(for R in $TO; do echo -n "--to='$R' "; done)
|
GIT_TO=$(for R in $TO; do echo -n "--to='$R' "; done)
|
||||||
GIT_CC=$(for R in $CC; do echo -n "--cc='$R' "; done)
|
GIT_CC=$(for R in $CC; do echo -n "--cc='$R' "; done)
|
||||||
unset IFS
|
unset IFS
|
||||||
for PATCH in $PDIR/*patch; do
|
for PATCH in $PDIR/*patch; do
|
||||||
# We harvest the emails manually, so force git not to.
|
# We harvest the emails manually, so force git not to.
|
||||||
eval "git send-email $GIT_TO $GIT_CC --no-chain-reply-to --suppress-cc=all $PATCH"
|
eval "git send-email $GIT_TO $GIT_CC --no-chain-reply-to --suppress-cc=all $PATCH"
|
||||||
if [ $? -eq 1 ]; then
|
if [ $? -eq 1 ]; then
|
||||||
ERROR=1
|
ERROR=1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
sendmail)
|
sendmail)
|
||||||
for PATCH in $PDIR/*patch; do
|
for PATCH in $PDIR/*patch; do
|
||||||
# Insert To and CC headers via formail to keep them separate and
|
# Insert To and CC headers via formail to keep them separate and
|
||||||
# appending them to the sendmail command as -- $TO $CC has
|
# appending them to the sendmail command as -- $TO $CC has
|
||||||
# proven to be an exercise in futility.
|
# proven to be an exercise in futility.
|
||||||
#
|
#
|
||||||
# Clear the From header, leaving it up to sendmail to insert an
|
# Clear the From header, leaving it up to sendmail to insert an
|
||||||
# appropriate one. Insert the original sender (per git) into the
|
# appropriate one. Insert the original sender (per git) into the
|
||||||
# body of the message.
|
# body of the message.
|
||||||
#
|
#
|
||||||
# Use tail to remove the email envelope from git or formail as
|
# Use tail to remove the email envelope from git or formail as
|
||||||
# msmtp (sendmail) would choke on them.
|
# msmtp (sendmail) would choke on them.
|
||||||
#
|
#
|
||||||
# Modify the patch date for sequential delivery, but retain the
|
# Modify the patch date for sequential delivery, but retain the
|
||||||
# original date as "Old-Date".
|
# original date as "Old-Date".
|
||||||
DATE=$(date +"%a, %d %b %Y %k:%M:%S %z")
|
DATE=$(date +"%a, %d %b %Y %k:%M:%S %z")
|
||||||
GIT_FROM=$(cat $PATCH | formail -X "From:")
|
GIT_FROM=$(cat $PATCH | formail -X "From:")
|
||||||
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
|
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
|
||||||
if [ $? -eq 1 ]; then
|
if [ $? -eq 1 ]; then
|
||||||
ERROR=1
|
ERROR=1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "ERROR: unknown MTA: $PULL_MTA"
|
echo "ERROR: unknown MTA: $PULL_MTA"
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ $ERROR -eq 1 ]; then
|
if [ $ERROR -eq 1 ]; then
|
||||||
echo "ERROR: Failed to send one or more messages. Check your MTA log for details."
|
echo "ERROR: Failed to send one or more messages. Check your MTA log for details."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Send aborted."
|
echo "Send aborted."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue