-
-
Save shvargon/1fefd3e4d92df4ae627f8246eb5f2f91 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
#!/usr/bin/env bash | |
# Put in your Rust repository's .git/hooks/pre-commit to ensure you never breaks rustfmt. | |
for FILE in `git diff --cached --name-only`; do | |
if [[ $FILE == *.rs ]] && ! rustfmt --edition=2018 --check $FILE; then | |
echo -e "\n Commit rejected due to invalid formatting of \"$FILE\" file." | |
exit 1 | |
fi | |
done |
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
# default 2018 edition | |
# https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#edition | |
edition = "2018" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment