diff options
| author | Lex Neva <lexelby@users.noreply.github.com> | 2024-09-14 18:56:00 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-14 18:56:00 -0400 |
| commit | 832124bc5b33996e585480933e57d93b0bd8dbe3 (patch) | |
| tree | 5c81a3f5bf452968f3c0fe49f08fad497a89a71f /bin/git-pre-commit-hook | |
| parent | 207395d581a74e8e5893e38c9b309730b02da955 (diff) | |
only style-check staged changes (#3186)
Diffstat (limited to 'bin/git-pre-commit-hook')
| -rwxr-xr-x | bin/git-pre-commit-hook | 17 |
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 |
