Skip to content

Commit 3208e42

Browse files
committed
pseudo-lint is only run on files staged for commit
Why: A commit shouldn't have to fix problems unrelated to its main purpose.
1 parent 98d0a9a commit 3208e42

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

.githooks/pre-commit

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ EOF
3939
exit 1
4040
fi
4141

42-
# runs pseudo-lint
43-
mix format --check-formatted '{lib,priv,test,config}/**/*.{ex,exs}'
42+
# runs pseudo-lint on staged files
43+
git diff --name-only --cached | grep -E ".*\.(ex|exs)$" | xargs mix format --check-formatted
4444

4545
PSEUDOLINT_STATUS=$?
4646
if [ "$PSEUDOLINT_STATUS" != "0" ]; then
47-
echo 'run `mix format`'
47+
echo 'run `mix format` then `git add ...` to restage the formatted file'
4848
exit $PSEUDOLINT_STATUS
4949
fi

0 commit comments

Comments
 (0)