on veut des status pas des diff :/

This commit is contained in:
Jérémy Lecour 2018-09-20 15:56:25 +02:00 committed by Jérémy Lecour
parent 07f5f1a624
commit 6e377cedca

View file

@ -39,8 +39,8 @@ END_DATE=$(date +"%Y %b %d %H:%M")
# we can't use "date --iso8601" because this options is not available everywhere # we can't use "date --iso8601" because this options is not available everywhere
NOW_ISO=$(date +"%Y-%m-%dT%H:%M:%S%z") NOW_ISO=$(date +"%Y-%m-%dT%H:%M:%S%z")
# git diffs # git statuses
GIT_DIFFS="" GIT_STATUSES=""
if test -x "${GIT_BIN}"; then if test -x "${GIT_BIN}"; then
# loop on possible directories managed by GIT # loop on possible directories managed by GIT
@ -51,17 +51,17 @@ if test -x "${GIT_BIN}"; then
if test -d "${GIT_DIR}" && test -d "${GIT_WORK_TREE}"; then if test -d "${GIT_DIR}" && test -d "${GIT_WORK_TREE}"; then
CHANGED_LINES=$(${GIT_BIN} status --porcelain | wc -l) CHANGED_LINES=$(${GIT_BIN} status --porcelain | wc -l)
if [ "${CHANGED_LINES}" != "0" ]; then if [ "${CHANGED_LINES}" != "0" ]; then
DIFF=$(${GIT_BIN} diff --stat | tail -n 10) STATUS=$(${GIT_BIN} status --short | tail -n 10)
# append diff data, without empty lines # append diff data, without empty lines
GIT_DIFFS=$(echo "${GIT_DIFFS}\n${GIT_DIR} (last 10 lines)\n${DIFF}\n" | sed -e '/^$/d') GIT_STATUSES=$(echo "${GIT_STATUSES}\n${GIT_DIR} (last 10 lines)\n${STATUS}\n" | sed -e '/^$/d')
fi fi
fi fi
# unset environment variables to prevent accidental influence on other git commands # unset environment variables to prevent accidental influence on other git commands
unset GIT_DIR GIT_WORK_TREE unset GIT_DIR GIT_WORK_TREE
done done
if [ -n "${GIT_DIFFS}" ]; then if [ -n "${GIT_STATUSES}" ]; then
echo "/!\ There are some uncommited changes. If you proceed, everything will be commited." echo "/!\ There are some uncommited changes. If you proceed, everything will be commited."
echo "${GIT_DIFFS}" echo "${GIT_STATUSES}"
echo "" echo ""
fi fi
fi fi