fix pre-commit hook and code quality fixes

This commit is contained in:
counterweight 2025-12-21 22:14:48 +01:00
parent d2fc802ef9
commit 607f872c71
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
3 changed files with 27 additions and 11 deletions

View file

@ -1,12 +1,20 @@
#!/bin/bash
# Pre-commit hook to ensure generated types and constants are up-to-date
# Pre-commit hook to run code quality tools and ensure generated types are up-to-date
set -e
echo "🔍 Checking shared constants..."
cd backend && uv run python validate_constants.py
cd ..
# 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
@ -15,13 +23,19 @@ if git diff --cached --name-only | grep -q "frontend/app/generated/api.ts"; then
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
# 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 "✅ Pre-commit checks passed"
echo ""
echo "✅ All pre-commit checks passed"