Skip to content

Commit

Permalink
DRY in pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
anttiharju committed Sep 2, 2024
1 parent 2b42d25 commit ed381fc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit ed381fc

Please sign in to comment.