Created
December 13, 2017 14:59
-
-
Save zeenix/e09e829120546592d68d56b2b60f0cd0 to your computer and use it in GitHub Desktop.
git hook to ensure commit doesn't break rustfmt
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 | |
# Put in your Rust repository's .git/hooks/pre-commit to ensure you never | |
# breaks rustfmt. | |
# | |
# WARNING: rustfmt is a fast moving target so ensure you have the version that | |
# all contributors have. | |
for FILE in `git diff --cached --name-only`; do | |
#if [[ $FILE == *.rs ]] && ! rustup run nightly rustfmt --write-mode diff --skip-children $FILE; then | |
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