Created
November 20, 2017 17:03
-
-
Save zeenix/d797e299ae0000e471359ec2844acaae to your computer and use it in GitHub Desktop.
Git pre-commit hook to ensure your changes don't break rustfmt formatting rules
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 | |
for FILE in `git diff --cached --name-only`; do | |
if [[ $FILE == *.rs ]] && ! rustfmt --write-mode diff --skip-children $FILE; then | |
echo "Commit rejected due to invalid formatting of \"$FILE\" file." | |
exit 1 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice!
iirc, the [[ construct is bash specific and might not be supported in all variants of /bin/sh.