summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorLex Neva <lexelby@users.noreply.github.com>2024-09-14 18:56:00 -0400
committerGitHub <noreply@github.com>2024-09-14 18:56:00 -0400
commit832124bc5b33996e585480933e57d93b0bd8dbe3 (patch)
tree5c81a3f5bf452968f3c0fe49f08fad497a89a71f /bin
parent207395d581a74e8e5893e38c9b309730b02da955 (diff)
only style-check staged changes (#3186)
Diffstat (limited to 'bin')
-rwxr-xr-xbin/git-pre-commit-hook17
1 files changed, 12 insertions, 5 deletions
diff --git a/bin/git-pre-commit-hook b/bin/git-pre-commit-hook
index 81ace2cd..4d81c5a7 100755
--- a/bin/git-pre-commit-hook
+++ b/bin/git-pre-commit-hook
@@ -7,11 +7,18 @@
# DO NOT SYMLINK
# DO NOT SYMLINK (why? security risk)
+check_errors() {
+ errors="$("$@")"
+
+ if [ "$?" != "0" ]; then
+ echo "$errors"
+ exit 1
+ fi
+}
+
cd $(dirname "$0")/../..
-errors=$(git diff --cached | bin/style-check --diff 2>&1)
+check_errors git stash --keep-index
+check_errors git diff --cached | bin/style-check 2>&1
+check_errors git stash pop
-if [ "$?" != "0" ]; then
- echo "$errors"
- exit 1
-fi