Skip to content

Instantly share code, notes, and snippets.

@withzombies
Created April 30, 2025 19:59
Show Gist options
  • Save withzombies/cabb08f00377a4d6d7fbb0532f51e15f to your computer and use it in GitHub Desktop.
Save withzombies/cabb08f00377a4d6d7fbb0532f51e15f to your computer and use it in GitHub Desktop.
rust git recommit script
#!/bin/bash
# Check formatting
echo "Checking formatting with cargo fmt..."
if ! cargo fmt --all -- --check; then
echo "Error: Code is not formatted. Please run 'cargo fmt --all' before committing."
exit 1
fi
# Run Clippy linter
echo "Running cargo clippy..."
if ! cargo clippy --all-targets --all-features -- -D warnings; then
echo "Error: Clippy found warnings or errors. Please fix them before committing."
exit 1
fi
# Run tests
echo "Running tests with cargo test..."
if ! cargo test --all; then
echo "Error: Some tests failed. Please fix them before committing."
exit 1
fi
echo "All checks passed. Proceeding with commit."
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment