Skip to content

Instantly share code, notes, and snippets.

@veelenga
Created April 20, 2017 08:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save veelenga/b032990576bbccda4e1839d43064e039 to your computer and use it in GitHub Desktop.
Save veelenga/b032990576bbccda4e1839d43064e039 to your computer and use it in GitHub Desktop.
Git pre-commit hook to format Crystal code
#!/bin/sh
crystal tool format --check &> /dev/null
ret_code=$?
if [ 0 -ne $ret_code ]; then
crystal tool format
echo "Files formatted. Please review results and commit ;)"
exit $ret_code
else
exit 0
fi
@veelenga
Copy link
Author

veelenga commented Apr 20, 2017

Place the content into your_crystal_repo/.git/hooks/pre-commit and it will force you to format code before doing a commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment