set -e
ignored_files=$(git ls-files --cached --ignored --exclude-standard 2>/dev/null || true)
if [ -n "$ignored_files" ]; then
echo "ERROR: The following staged files match .gitignore patterns:"
echo ""
echo "$ignored_files" | while read -r f; do echo " $f"; done
echo ""
echo "Remove them from tracking with: git rm --cached <file>"
exit 1
fi
if ! cargo fmt --all -- --check; then
echo ""
echo "Formatting check failed. Run 'cargo fmt --all' to fix."
exit 1
fi
if ! RUSTFLAGS="-Dwarnings" cargo clippy --all-targets --all-features; then
echo ""
echo "Clippy check failed. Fix warnings before committing."
exit 1
fi
exit 0