Skip to content

Instantly share code, notes, and snippets.

@Nejat
Created December 4, 2022 09:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nejat/9ad815f46596ddc8b0f0c12916d1af55 to your computer and use it in GitHub Desktop.
Save Nejat/9ad815f46596ddc8b0f0c12916d1af55 to your computer and use it in GitHub Desktop.
git pre-commit hook for rust projects
#!/bin/sh
set -eu
# if ! cargo fmt -- --check
# then
# echo "check/fix fmt issues ..."
# exit -1
# fi
if ! cargo clippy --all-targets --release -- -D warnings
then
echo "check/fix clippy issues ..."
exit 1
fi
if ! cargo test --all --release
then
echo "check/fix failed test issues .."
exit 2
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment