Skip to content

Instantly share code, notes, and snippets.

@Daniel-Worrall
Last active July 31, 2021 11:47
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Daniel-Worrall/d8b060ba1289d4ee63277d8504eaab55 to your computer and use it in GitHub Desktop.
Save Daniel-Worrall/d8b060ba1289d4ee63277d8504eaab55 to your computer and use it in GitHub Desktop.
Crystal pre-commit - Just put in .git/hooks folder
#!/bin/sh
changed_cr_files=$(git diff --cached --name-only --diff-filter=ACM | grep '\.cr$')
[ -z "$changed_cr_files" ] && exit 0
crystal tool format $changed_cr_files
shards check || exit 1
bin/ameba -f flycheck $changed_cr_files || exit 1
crystal spec --fail-fast >/dev/null || echo "Specs failed."; exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment