#!/bin/bash # .git/hooks/pre-commit # requires uv # Track overall status PASS=true # Color output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color echo -e "${YELLOW}Running pre-commit checks...${NC}" PY_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep '\.py$') # Python checks if [ -n "$PY_FILES" ]; then echo -e "${YELLOW}Checking Python files...${NC}" if ! uvx ruff check --extend-exclude=.*,build*; then PASS=false fi fi # Final status if [ "$PASS" = true ]; then echo -e "${GREEN}All checks passed!${NC}" exit 0 else echo -e "${RED}Some checks failed. Please fix issues before committing.${NC}" exit 1 fi