CMD=$(basename "$0")
warn () { echo "$CMD: $*" >&2; }
die () { echo "$CMD: $*" >&2; exit 1; }
warn "🚀 Running Pre-Commit Checks"
make check
if [ $? -ne 0 ]; then
die "❌ Formatting or Clippy failed. Fix errors before committing."
fi
make test-quiet
if [ $? -ne 0 ]; then
die "❌ Tests failed. Fix errors before committing."
fi
make audit
if [ $? -ne 0 ]; then
die "❌ Security audit failed! Check your dependencies."
fi
MSRV=$(grep -m 1 '^rust-version' Cargo.toml | cut -d '"' -f 2)
if [ -z "$MSRV" ]; then
die "No rust-version found in Cargo.toml. Skipping MSRV check."
fi
warn "Checking MSRV compatibility ($MSRV)..."
rustup run "$MSRV" cargo check --locked --profile dev
if [ $? -ne 0 ]; then
die "MSRV Check Failed! Please fix compatibility issues before committing."
fi
warn "✅ All checks passed. Committing..."
exit 0