Skip to content

Commit

Permalink
cardano-cli: pre-commit: fail on hlint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
smelc committed Sep 20, 2023
1 parent 564c7e6 commit 1fbafcc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions scripts/githooks/haskell-style-lint
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@
# ln -s $(git-root)/scripts/githooks/haskell-style-lint $(git rev-parse --git-dir)/hooks/pre-commit
#

hlint_rc="0"

for x in $(git diff --staged --name-only --diff-filter=ACM "*.hs" | tr '\n' ' '); do
if grep -qE '^#' "$x"; then
echo "$x contains CPP. Skipping."
else
stylish-haskell -i "$x"
fi
# fail on linting issues
hlint "$x"
hlint "$x" || hlint_rc="1"
done

# fail if there are style issues
git --no-pager diff --exit-code
git --no-pager diff --exit-code || exit 1
# if there are no style issue, there could be hlint issues:
exit $hlint_rc

0 comments on commit 1fbafcc

Please sign in to comment.