arbret/.githooks/pre-commit
2025-12-20 23:09:46 +01:00

27 lines
859 B
Bash
Executable file

#!/bin/bash
# Pre-commit hook to ensure generated types and constants are up-to-date
set -e
echo "🔍 Checking shared constants..."
cd backend && uv run python validate_constants.py
cd ..
echo "🔍 Checking if generated types are fresh..."
# Check if api.ts is staged
if git diff --cached --name-only | grep -q "frontend/app/generated/api.ts"; then
echo "✓ Generated types are staged"
else
# Check if backend schema files have changed
if git diff --cached --name-only | grep -qE "backend/(schemas|models|routes)"; then
echo "⚠️ Backend schema files changed but generated types not staged."
echo " Run 'make generate-types-standalone' and stage the changes."
echo ""
echo " To skip this check (not recommended): git commit --no-verify"
exit 1
fi
fi
echo "✅ Pre-commit checks passed"