crftng-intrprtrs/pre-commit-hook.sh
2022-05-07 20:02:50 +02:00

27 lines
528 B
Bash
Executable file

#!/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 --all -- --check
then
echo "There are some code style issues."
echo "Run cargo fmt first."
exit 1
fi
if ! cargo clippy --all-targets --workspace -- -D warnings
then
echo "There are some clippy issues."
exit 1
fi
if ! cargo test --workspace
then
echo "There are some test issues."
exit 1
fi
exit 0