crftng-intrprtrs/pre-commit-hook.sh

28 lines
528 B
Bash
Raw Normal View History

2022-04-03 22:10:55 +02:00
#!/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
2022-05-07 20:02:50 +02:00
if ! cargo fmt --all -- --check
2022-04-03 22:10:55 +02:00
then
echo "There are some code style issues."
echo "Run cargo fmt first."
exit 1
fi
2022-05-07 20:02:50 +02:00
if ! cargo clippy --all-targets --workspace -- -D warnings
2022-04-03 22:10:55 +02:00
then
echo "There are some clippy issues."
exit 1
fi
2022-05-07 20:02:50 +02:00
if ! cargo test --workspace
2022-04-03 22:10:55 +02:00
then
echo "There are some test issues."
exit 1
fi
exit 0