From e8fb49cfb4f1f6d0d39c7d6cf4d369c2e0724cb2 Mon Sep 17 00:00:00 2001 From: Alex Selimov Date: Tue, 16 Jan 2024 13:27:42 -0500 Subject: [PATCH] Make commit fail if formatter fails --- pre-commit | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pre-commit b/pre-commit index 7801435..c00b1a6 100755 --- a/pre-commit +++ b/pre-commit @@ -13,8 +13,11 @@ if hash black 2>/dev/null; then # Only run if we have cached python files if [ "$cached_files" ]; then - black --line-length 100 $cached_files - git add $cached_files + black --line-length 100 $cached_files \ + && git add $cached_files \ + || exit 1 + + fi else @@ -30,8 +33,9 @@ if hash idea.sh 2>/dev/null; then if [ "$cached_files" ]; then - idea.sh format -allowDefaults $cached_files 2>/dev/null - git add $cached_files + idea.sh format -allowDefaults $cached_files 2>/dev/null \ + && git add $cached_files \ + || exit 1 fi else echo "intellij isn't installed so not formatting java code"