41 lines
1.3 KiB
Bash
Executable file
41 lines
1.3 KiB
Bash
Executable file
#!/bin/bash
|
|
# Pre-commit hook to run code quality tools and ensure generated types are up-to-date
|
|
|
|
set -e
|
|
|
|
# Get the root of the repository
|
|
REPO_ROOT="$(git rev-parse --show-toplevel)"
|
|
cd "$REPO_ROOT"
|
|
|
|
echo "🔧 Running code quality checks (ruff, mypy, bandit, eslint, prettier)..."
|
|
echo ""
|
|
|
|
# Run pre-commit framework hooks on staged files
|
|
cd backend && uv run pre-commit run
|
|
cd "$REPO_ROOT"
|
|
|
|
echo ""
|
|
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
|
|
# Check if api.ts has unstaged changes (meaning types need to be staged)
|
|
if git diff --name-only | grep -q "frontend/app/generated/api.ts"; then
|
|
echo "⚠️ Backend schema files changed and generated types have unstaged changes."
|
|
echo " Run 'git add frontend/app/generated/api.ts' to stage the changes."
|
|
echo ""
|
|
echo " To skip this check (not recommended): git commit --no-verify"
|
|
exit 1
|
|
else
|
|
echo "✓ Generated types are up to date (no changes needed)"
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
echo ""
|
|
echo "✅ All pre-commit checks passed"
|
|
|