long and short commit information
This commit is contained in:
parent
80087f3c38
commit
c9c061f811
|
@ -8,7 +8,7 @@
|
|||
# Copyright 2007-2019 Evolix <info@evolix.fr>, Gregory Colpart <reg@evolix.fr>,
|
||||
# Jérémy Lecour <jlecour@evolix.fr> and others.
|
||||
|
||||
VERSION="0.5.0.beta4"
|
||||
VERSION="0.5.0.beta5"
|
||||
|
||||
show_version() {
|
||||
cat <<END
|
||||
|
@ -122,8 +122,8 @@ get_repository_status() {
|
|||
if [ -d "${GIT_DIR}" ] && [ -d "${GIT_WORK_TREE}" ]; then
|
||||
CHANGED_LINES=$(${GIT_BIN} status --porcelain | wc -l | tr -d ' ')
|
||||
if [ "${CHANGED_LINES}" != "0" ]; then
|
||||
STATUS=$(${GIT_BIN} status --short | tail -n 10)
|
||||
printf "%s\n%s\n" "${GIT_DIR} (last 10 lines)" "${STATUS}" | sed -e '/^$/d'
|
||||
STATUS=$(${GIT_BIN} status --short | tail -n ${GIT_STATUS_MAX_LINES})
|
||||
printf "%s\n%s\n" "${GIT_DIR} (last ${GIT_STATUS_MAX_LINES} lines)" "${STATUS}" | sed -e '/^$/d'
|
||||
fi
|
||||
fi
|
||||
# unset environment variables to prevent accidental influence on other git commands
|
||||
|
@ -160,16 +160,20 @@ hook_commit() {
|
|||
CHANGED_LINES=$(${GIT_BIN} status --porcelain | wc -l | tr -d ' ')
|
||||
if [ "${CHANGED_LINES}" != "0" ]; then
|
||||
if [ "${DRY_RUN}" = "1" ]; then
|
||||
STATS=$(${GIT_BIN} diff --stat | tail -1)
|
||||
GIT_COMMITS=$(printf "%s\n%s : %s" "${GIT_COMMITS}" "${GIT_DIR}" "${STATS}" | sed -e '/^$/d')
|
||||
STATS_SHORT=$(${GIT_BIN} diff --stat | tail -1)
|
||||
STATS=$(${GIT_BIN} diff --stat | tail -n ${GIT_STATUS_MAX_LINES})
|
||||
GIT_COMMITS_SHORT=$(printf "%s\n%s : %s" "${GIT_COMMITS_SHORT}" "${GIT_DIR}" "${STATS_SHORT}" | sed -e '/^$/d')
|
||||
GIT_COMMITS=$(printf "%s\n%s\n%s" "${GIT_COMMITS}" "${GIT_DIR}" "${STATS}" | sed -e '/^$/d')
|
||||
else
|
||||
${GIT_BIN} add --all
|
||||
${GIT_BIN} commit --message "${MESSAGE}" --author="${USER} <${USER}@evolix.net>" --quiet
|
||||
# Add the SHA to the log file if something has been committed
|
||||
SHA=$(${GIT_BIN} rev-parse --short HEAD)
|
||||
STATS=$(${GIT_BIN} show --stat | tail -1)
|
||||
STATS_SHORT=$(${GIT_BIN} show --stat | tail -1)
|
||||
STATS=$(${GIT_BIN} show --stat | tail -n ${GIT_STATUS_MAX_LINES})
|
||||
# append commit data, without empty lines
|
||||
GIT_COMMITS=$(printf "%s\n%s : %s –%s" "${GIT_COMMITS}" "${GIT_DIR}" "${SHA}" "${STATS}" | sed -e '/^$/d')
|
||||
GIT_COMMITS_SHORT=$(printf "%s\n%s : %s –%s" "${GIT_COMMITS_SHORT}" "${GIT_DIR}" "${SHA}" "${STATS_SHORT}" | sed -e '/^$/d')
|
||||
GIT_COMMITS=$(printf "%s\n%s : %s\n%s" "${GIT_COMMITS}" "${GIT_DIR}" "${SHA}" "${STATS}" | sed -e '/^$/d')
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
@ -246,9 +250,11 @@ HOOK_MAIL=${HOOK_MAIL:-"1"}
|
|||
DRY_RUN=${DRY_RUN:-"0"}
|
||||
VERBOSE=${VERBOSE:-"0"}
|
||||
AUTO=${AUTO:-"0"}
|
||||
GIT_STATUS_MAX_LINES=${GIT_STATUS_MAX_LINES:-20}
|
||||
|
||||
# initialize variables
|
||||
MESSAGE=""
|
||||
GIT_COMMITS_SHORT=""
|
||||
GIT_COMMITS=""
|
||||
|
||||
# Parse options
|
||||
|
|
Loading…
Reference in a new issue