Created
November 5, 2021 16:41
-
-
Save gabrik/9776cfab5b81649ef1a713116fb01c70 to your computer and use it in GitHub Desktop.
pre-commit and pre-push hooks for Cargo
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/bash | |
diff=$(cargo fmt -- --check) | |
result=$? | |
if [[ ${result} -ne 0 ]] ; then | |
cat <<\EOF | |
There are some code style issues, run `cargo fmt` first. | |
EOF | |
exit 1 | |
fi | |
diff=$(cargo clippy --all --all-targets) | |
result=$? | |
if [[ ${result} -ne 0 ]] ; then | |
cat <<\EOF | |
There are some code issues, please solve them first. | |
EOF | |
exit 1 | |
fi | |
exit 0 | |
diff=$(cargo check --all-targets) | |
result=$? | |
if [[ ${result} -ne 0 ]] ; then | |
cat <<\EOF | |
There are some code issues, please solve them first. | |
EOF | |
exit 1 | |
fi | |
exit 0 |
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/bash | |
diff=$(cargo test) | |
result=$? | |
if [[ ${result} -ne 0 ]] ; then | |
cat <<\EOF | |
Tests are failing, solve the bugs first. | |
EOF | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment