Created
July 5, 2025 03:44
-
-
Save rain2307/24dabfecc1a4d70933411718794e3e5c to your computer and use it in GitHub Desktop.
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 | |
# Pre-commit hook for Rust project | |
# This hook runs cargo fmt and cargo clippy before allowing commits | |
set -e | |
echo "Running cargo fmt..." | |
cargo fmt -- --check | |
if [ $? -ne 0 ]; then | |
echo "Code formatting issues found. Please run 'cargo fmt' to fix them." | |
exit 1 | |
fi | |
echo "Running cargo clippy..." | |
cargo clippy -- -D warnings | |
if [ $? -ne 0 ]; then | |
echo "Clippy found issues. Please fix them before committing." | |
exit 1 | |
fi | |
echo "Pre-commit checks passed!"% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
.git/hooks/pre-commit