From ee93e19130be972acfba30d86d05fe41b7b259aa Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Thu, 6 Sep 2018 12:22:35 +0200 Subject: [PATCH] don't try to commit if nothing has changed --- evomaintenance.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/evomaintenance.sh b/evomaintenance.sh index d486052..7b2129b 100644 --- a/evomaintenance.sh +++ b/evomaintenance.sh @@ -61,10 +61,11 @@ if test -x "${GIT_BIN}"; then export GIT_DIR="${dir}/.git" GIT_WORK_TREE="${dir}" # If the repository and the work tree exist, try to commit changes if test -d "${GIT_DIR}" && test -d "${GIT_WORK_TREE}"; then - ${GIT_BIN} add --all - ${GIT_BIN} commit --message "${TEXTE}" --author="${USER} <${USER}@evolix.net>" --quiet - # Add the SHA to the log file if something has been committed - if [ "$?" = "0" ]; then + CHANGED_LINES=$(git status --porcelain | wc -l) + if [ "${CHANGED_LINES}" != "0" ]; then + ${GIT_BIN} add --all + ${GIT_BIN} commit --message "${TEXTE}" --author="${USER} <${USER}@evolix.net>" --quiet + # Add the SHA to the log file if something has been committed SHA=$(git rev-parse HEAD) echo "${dir} : ${SHA}" >> "${LOGFILE}" fi