Merge branch 'kf/post-receive-sample-hook' into maint
* kf/post-receive-sample-hook: post-receive-email: ensure sent messages are not empty
This commit is contained in:
commit
6cf9bf6cbc
@ -71,19 +71,10 @@
|
|||||||
# ---------------------------- Functions
|
# ---------------------------- Functions
|
||||||
|
|
||||||
#
|
#
|
||||||
# Top level email generation function. This decides what type of update
|
# Function to prepare for email generation. This decides what type
|
||||||
# this is and calls the appropriate body-generation routine after outputting
|
# of update this is and whether an email should even be generated.
|
||||||
# the common header
|
|
||||||
#
|
#
|
||||||
# Note this function doesn't actually generate any email output, that is
|
prep_for_email()
|
||||||
# taken care of by the functions it calls:
|
|
||||||
# - generate_email_header
|
|
||||||
# - generate_create_XXXX_email
|
|
||||||
# - generate_update_XXXX_email
|
|
||||||
# - generate_delete_XXXX_email
|
|
||||||
# - generate_email_footer
|
|
||||||
#
|
|
||||||
generate_email()
|
|
||||||
{
|
{
|
||||||
# --- Arguments
|
# --- Arguments
|
||||||
oldrev=$(git rev-parse $1)
|
oldrev=$(git rev-parse $1)
|
||||||
@ -159,7 +150,7 @@ generate_email()
|
|||||||
# Anything else (is there anything else?)
|
# Anything else (is there anything else?)
|
||||||
echo >&2 "*** Unknown type of update to $refname ($rev_type)"
|
echo >&2 "*** Unknown type of update to $refname ($rev_type)"
|
||||||
echo >&2 "*** - no email generated"
|
echo >&2 "*** - no email generated"
|
||||||
exit 1
|
return 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@ -175,9 +166,32 @@ generate_email()
|
|||||||
esac
|
esac
|
||||||
echo >&2 "*** $config_name is not set so no email will be sent"
|
echo >&2 "*** $config_name is not set so no email will be sent"
|
||||||
echo >&2 "*** for $refname update $oldrev->$newrev"
|
echo >&2 "*** for $refname update $oldrev->$newrev"
|
||||||
exit 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Top level email generation function. This calls the appropriate
|
||||||
|
# body-generation routine after outputting the common header.
|
||||||
|
#
|
||||||
|
# Note this function doesn't actually generate any email output, that is
|
||||||
|
# taken care of by the functions it calls:
|
||||||
|
# - generate_email_header
|
||||||
|
# - generate_create_XXXX_email
|
||||||
|
# - generate_update_XXXX_email
|
||||||
|
# - generate_delete_XXXX_email
|
||||||
|
# - generate_email_footer
|
||||||
|
#
|
||||||
|
# Note also that this function cannot 'exit' from the script; when this
|
||||||
|
# function is running (in hook script mode), the send_mail() function
|
||||||
|
# is already executing in another process, connected via a pipe, and
|
||||||
|
# if this function exits without, whatever has been generated to that
|
||||||
|
# point will be sent as an email... even if nothing has been generated.
|
||||||
|
#
|
||||||
|
generate_email()
|
||||||
|
{
|
||||||
# Email parameters
|
# Email parameters
|
||||||
# The email subject will contain the best description of the ref
|
# The email subject will contain the best description of the ref
|
||||||
# that we can build from the parameters
|
# that we can build from the parameters
|
||||||
@ -717,10 +731,11 @@ if [ -n "$1" -a -n "$2" -a -n "$3" ]; then
|
|||||||
# Output to the terminal in command line mode - if someone wanted to
|
# Output to the terminal in command line mode - if someone wanted to
|
||||||
# resend an email; they could redirect the output to sendmail
|
# resend an email; they could redirect the output to sendmail
|
||||||
# themselves
|
# themselves
|
||||||
PAGER= generate_email $2 $3 $1
|
prep_for_email $2 $3 $1 && PAGER= generate_email
|
||||||
else
|
else
|
||||||
while read oldrev newrev refname
|
while read oldrev newrev refname
|
||||||
do
|
do
|
||||||
generate_email $oldrev $newrev $refname $maxlines | send_mail
|
prep_for_email $oldrev $newrev $refname || continue
|
||||||
|
generate_email $maxlines | send_mail
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user