Skip to content

Instantly share code, notes, and snippets.

@jhedev
Last active August 29, 2015 13:58
Show Gist options
  • Save jhedev/9970801 to your computer and use it in GitHub Desktop.
Save jhedev/9970801 to your computer and use it in GitHub Desktop.
# 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