esp-hal/pre-commit
Jesse Braham d316b066b0 Improve the pre-commit hook
Now handles directories starting with `esp` which do *not* contain a `Cargo.toml` file!
2023-05-11 08:53:03 -07:00

15 lines
584 B
Bash
Executable File

#!/usr/bin/env bash
# Exit immediately on first non-zero status from a command in the script.
set -o errexit
# Ensure all tools being used are available.
command -v "cargo" >/dev/null 2>&1 || { echo >&2 "The 'cargo' command is not installed, exiting"; exit 1; }
command -v "rustfmt" >/dev/null 2>&1 || { echo >&2 "The 'rustfmt' command is not installed, exiting"; exit 1; }
# Check the formatting of all Rust code for every package.
for manifest in "esp"*/Cargo.toml; do
# Check package is correctly formatted.
cargo fmt --all --manifest-path "${manifest}" -- --check
done