Last active
August 29, 2015 13:58
-
-
Save jhedev/9970801 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Taken from https://github.com/HIPERFIT/L0Language/blob/master/git-hooks/pre-commit | |
fail() { | |
echo "Aborting commit due to verification errors." | |
echo "If you disagree, use git commit --no-verify." | |
exit 1 | |
} | |
hlintable() { | |
! egrep -q '{-# LANGUAGE.*QuasiQuotes' $1 | |
} | |
l0_hlint() { | |
# Some hlint-suggestions are terrible, so ignore them here. | |
hlint -i "Reduce duplication" -i "Use import/export shortcut" "$@" | |
} | |
# Run hlint on changed files. | |
for file in $(git diff-index --cached --name-only HEAD | egrep '\.l?hsc?$'); do | |
if [ -f $file ]; then | |
if hlintable $file; then | |
echo "Checking $file with hlint:" | |
if ! l0_hlint "$file"; then | |
fail | |
fi | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment