From ed381fcf410b601a200f831a716d6b1dfccf5b19 Mon Sep 17 00:00:00 2001 From: anttiharju Date: Mon, 2 Sep 2024 20:04:09 +0300 Subject: [PATCH] DRY in pre-commit --- .githooks/pre-commit | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index c651fbc..386bf4b 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -21,13 +21,16 @@ execute_if_modified() { echo "--no-verify can be used to skip git hooks." execute_if_modified 'make shellcheck' '*.sh' './.githooks/*' './bin/*' +prefix="You have" +postfix="changes; commit contents might not pass 'make ci'." + if ! git diff --quiet; then - echo "You have unstaged changes; commit contents might not pass 'make ci'." + echo "$prefix unstaged $postfix" exit 1 fi if [ -n "$(git ls-files --others --exclude-standard)" ]; then - echo "You have untracked changes; commit contents might not pass 'make ci'." + echo "$prefix untracked $postfix" exit 1 fi