fix(ui): fix pre-commit hook skipping lint, tests, and build (#10494)

This commit is contained in:
Alan Buscaglia authored and GitHub committed 2026-03-30 10:44:59 +02:00
1 parent de492a770c
commit 4ef0b1bf2c
1 file changed
+9 -9
+9 -9
View File
@@ -38,7 +38,8 @@ echo -e "${BLUE}ℹ️ Code Review Status: ${CODE_REVIEW_ENABLED}${NC}"
echo ""
# Get staged files in the UI folder only (what will be committed)
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM -- 'ui/**' | grep -E '\.(tsx?|jsx?)$' || true)
# Always use GIT_ROOT-relative pathspecs so detection works regardless of cwd
STAGED_FILES=$(git -C "$GIT_ROOT" diff --cached --name-only --diff-filter=ACM -- 'ui/' | grep -E '\.(tsx?|jsx?)$' || true)
if [ "$CODE_REVIEW_ENABLED" = "true" ]; then
if [ -z "$STAGED_FILES" ]; then
@@ -135,18 +136,17 @@ else
echo ""
fi
# Check if there are any UI files to validate
if [ -z "$STAGED_FILES" ] && [ "$CODE_REVIEW_ENABLED" = "true" ]; then
echo -e "${YELLOW}⏭️ No UI files to validate, skipping healthcheck${NC}"
# Run healthcheck (typecheck and lint check) only if there are UI changes
if [ -z "$STAGED_FILES" ]; then
echo -e "${YELLOW}⏭️ No UI files staged, skipping healthcheck/tests/build${NC}"
echo ""
exit 0
fi
# Run healthcheck (typecheck and lint check) only if there are UI changes
echo -e "${BLUE}🏥 Running healthcheck...${NC}"
echo ""
cd ui || cd .
cd "$GIT_ROOT/ui"
if pnpm run healthcheck; then
echo ""
echo -e "${GREEN}✅ Healthcheck passed${NC}"
@@ -164,11 +164,11 @@ echo -e "${BLUE}🧪 Running unit tests...${NC}"
echo ""
# Get staged source files (exclude test files)
# Note: we already cd'd into ui/, so pathspecs are relative (no ui/ prefix)
STAGED_SOURCE_FILES=$(git diff --cached --name-only --diff-filter=ACM -- '*.ts' '*.tsx' | grep -v '\.test\.\|\.spec\.\|vitest\.config\|vitest\.setup' || true)
# Use GIT_ROOT so pathspecs are always correct regardless of cwd
STAGED_SOURCE_FILES=$(git -C "$GIT_ROOT" diff --cached --name-only --diff-filter=ACM -- 'ui/*.ts' 'ui/*.tsx' | sed 's|^ui/||' | grep -v '\.test\.\|\.spec\.\|vitest\.config\|vitest\.setup' || true)
# Check if critical paths changed (lib/, types/, config/)
CRITICAL_PATHS_CHANGED=$(git diff --cached --name-only -- 'lib/**' 'types/**' 'config/**' 'middleware.ts' 'vitest.config.ts' 'vitest.setup.ts' || true)
CRITICAL_PATHS_CHANGED=$(git -C "$GIT_ROOT" diff --cached --name-only -- 'ui/lib/' 'ui/types/' 'ui/config/' 'ui/middleware.ts' 'ui/vitest.config.ts' 'ui/vitest.setup.ts' || true)
if [ -n "$CRITICAL_PATHS_CHANGED" ]; then
echo -e "${YELLOW}Critical paths changed - running ALL unit tests${NC}"