Skip to content

Instantly share code, notes, and snippets.

@rain2307
Created July 5, 2025 03:44
Show Gist options
  • Save rain2307/24dabfecc1a4d70933411718794e3e5c to your computer and use it in GitHub Desktop.
Save rain2307/24dabfecc1a4d70933411718794e3e5c to your computer and use it in GitHub Desktop.
#!/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!"%
@rain2307
Copy link
Author

rain2307 commented Jul 5, 2025

.git/hooks/pre-commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment