#!/bin/sh
# CodexCTL Pre-commit Hook
# Run: ./pre-commit to install, or add to your git config
echo "Running pre-commit checks..."
# Check formatting
if ! cargo fmt --check >/dev/null 2>&1; then
echo "Formatting errors detected. Running cargo fmt..."
cargo fmt
fi
# Check clippy
if ! cargo clippy -- -D warnings >/dev/null 2>&1; then
echo "Clippy warnings/errors detected."
cargo clippy -- -D warnings
exit 1
fi
echo "Pre-commit checks passed."
exit 0