Skip to content

Instantly share code, notes, and snippets.

@DefectingCat
Last active January 18, 2024 01:42
Show Gist options
  • Save DefectingCat/e280b1c6cf422169862be041225975ff to your computer and use it in GitHub Desktop.
Save DefectingCat/e280b1c6cf422169862be041225975ff to your computer and use it in GitHub Desktop.
Rust git pre commit hooks
#!/bin/sh
set -eu
if ! cargo fmt -- --check; then
echo "There are some code style issues."
echo "Run cargo fmt first."
exit 1
fi
if ! cargo clippy --all-targets -- -D warnings; then
echo "There are some clippy issues."
exit 1
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment