#!/bin/sh # https://deaddabe.fr/blog/2021/09/29/git-pre-commit-hook-for-rust-projects/ 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 if ! RUSTDOCFLAGS="-D warnings" cargo doc --no-deps then echo "There are some documentation issues." exit 1 fi exit 0