extract functions

This commit is contained in:
Jérémy Lecour 2019-03-09 21:42:05 +01:00
parent 997eff6ca7
commit c2b44f0e48

View file

@ -88,6 +88,30 @@ get_repository_status() {
unset GIT_DIR GIT_WORK_TREE
}
print_summary() {
BLOB=$(cat <<END
Host : $HOSTNAME_TEXT
User : $USER
IP : $IP
Begin : $BEGIN_DATE
End : $END_DATE
Message : $MESSAGE
END
)
echo "${BLOB}"
echo ""
}
print_options() {
echo "********** Options ****************"
echo "MESSAGE: ${MESSAGE}"
echo "OPT_COMMIT: ${OPT_COMMIT}"
echo "OPT_DB: ${OPT_DB}"
echo "OPT_MAIL: ${OPT_MAIL}"
echo "DRY_RUN: ${DRY_RUN}"
echo "***********************************\n"
}
hook_commit() {
GIT_COMMITS=""
@ -250,15 +274,8 @@ while :; do
shift
done
# Print options
if [ "${VERBOSE}" = "1" ]; then
echo "********** Options ****************"
echo "MESSAGE: ${MESSAGE}"
echo "OPT_COMMIT: ${OPT_COMMIT}"
echo "OPT_DB: ${OPT_DB}"
echo "OPT_MAIL: ${OPT_MAIL}"
echo "DRY_RUN: ${DRY_RUN}"
echo "***********************************\n"
print_options
fi
# Treat unset variables as an error when substituting.
@ -314,18 +331,7 @@ if test -z "${MESSAGE}"; then
exit 1
fi
# Display information
BLOB=$(cat <<END
Host : $HOSTNAME_TEXT
User : $USER
IP : $IP
Begin : $BEGIN_DATE
End : $END_DATE
Message : $MESSAGE
END
)
echo "${BLOB}"
echo ""
print_summary
# Log hook
if [ "${DRY_RUN}" != "1" ]; then