#!/usr/bin/env bash
set -euo pipefail

# Opt-out: SKIP_GITHOOKS=1 git commit -m "..."
if [[ "${SKIP_GITHOOKS:-}" == "1" ]]; then
  exit 0
fi

echo "[pre-commit] cargo fmt"
cargo fmt --quiet

echo "[pre-commit] cargo clippy"
cargo clippy --workspace --all-targets --all-features -- -D warnings

# If fmt changed files, add them to the commit
git add -A

