Add a pre-commit-hook
This commit is contained in:
parent
ef765220a2
commit
2c2cb00e2e
1 changed files with 27 additions and 0 deletions
27
pre-commit-hook.sh
Executable file
27
pre-commit-hook.sh
Executable file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# Stolen from
|
||||||
|
# https://deaddabe.fr/blog/2021/09/29/git-pre-commit-hook-for-rust-projects/
|
||||||
|
# Run `ln -s ../../pre-commit-hook.sh .git/hooks/pre-commit` to install
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
if ! cargo test
|
||||||
|
then
|
||||||
|
echo "There are some test issues."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
Loading…
Reference in a new issue