feat(hooks): add Husky git hooks for ui/goose2 (#8577)

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Matt Toohey
2026-04-21 18:08:27 +12:00
committed by GitHub
parent 70e12d9430
commit cbf893ced0
3 changed files with 103 additions and 5 deletions
+28 -2
View File
@@ -1,8 +1,34 @@
#!/usr/bin/env bash
set -e
# Only auto-format desktop TS code if relevant files are modified
if git diff --cached --name-only | grep -q "^ui/desktop/"; then
if git diff --cached --no-renames --name-only | grep -q "^ui/desktop/"; then
if [ -d "ui/desktop" ]; then
cd ui/desktop && pnpm exec lint-staged
(cd ui/desktop && pnpm exec lint-staged)
else
echo "Warning: ui/desktop directory does not exist, skipping lint-staged"
fi
fi
# Run goose2 checks if any staged files are under ui/goose2/
if git diff --cached --no-renames --name-only | grep -q '^ui/goose2/'; then
if [ -d "ui/goose2" ]; then
REPO_ROOT="$(pwd)"
echo "Running goose2 pre-commit checks..."
# Auto-format only staged files and re-stage them
STAGED_FILES=$(git diff --cached --no-renames --diff-filter=ACMR --name-only | grep '^ui/goose2/' | sed 's|^ui/goose2/||' || true)
if [ -n "$STAGED_FILES" ]; then
cd ui/goose2
echo "$STAGED_FILES" | xargs npx biome format --write
echo "$STAGED_FILES" | xargs npx biome check --fix
cd "$REPO_ROOT"
git diff --cached --no-renames --diff-filter=ACMR --name-only | grep '^ui/goose2/' | xargs git add
fi
# Run checks (biome check + file sizes + i18n + typecheck)
just goose2 check
else
echo "Warning: ui/goose2 directory does not exist, skipping goose2 checks"
fi
fi