Created
April 20, 2017 08:00
-
-
Save veelenga/b032990576bbccda4e1839d43064e039 to your computer and use it in GitHub Desktop.
Git pre-commit hook to format Crystal code
This file contains hidden or 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
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Place the content into
your_crystal_repo/.git/hooks/pre-commit
and it will force you to format code before doing a commit.