set -eu
echo "Running cargo fmt..."
if ! cargo fmt; then
echo >&2 "Pre-commit: formatting failed. Commit aborted."
exit 1
fi
echo "Running cargo clippy..."
if ! cargo clippy; then
echo >&2 "Pre-commit: Clippy failed. Commit aborted."
exit 1
fi
echo "Running cargo test..."
if ! cargo test; then
echo >&2 "Pre-commit: Tests failed. Commit aborted."
exit 1
fi
echo "Validating changelog generation..."
if ! git-cliff -o "CLIFF_CHANGELOG.md"; then
echo >&2 "Pre-commit: git-cliff validation failed. Check your commit messages follow conventional format."
echo >&2 "See CONTRIBUTING.md for git commit style guide."
exit 1
fi
echo "All checks passed. Proceeding with commit."