gendesign/scripts
lekss361 bd73ff2209 chore(claude): aggressive worktree cleanup via Forgejo PR API
Сложение к safe cleanup-merged-worktrees.sh — script на Python который
запрашивает Forgejo PR API чтобы поймать squash-merged branches (где local
SHA не ancestor remote main).

Decision matrix per worktree branch:
- merged (any style)    → REMOVE
- closed (no merge)     → REMOVE (abandoned)
- open                  → KEEP (active PR)
- no PR + age <14d      → KEEP (recent WIP)
- no PR + age >=14d     → REMOVE (stale orphan)

Two-phase removal:
1. git worktree remove --force --force (overrides Claude supervisor locks)
2. shutil.rmtree on orphan dirs (git-untracked but FS-leftover)

Graceful PermissionError handling — dirs locked by running Claude Code
supervisor printed with hint to re-run after restart.

Real run results (single pass, before this commit):
- Before: 102 worktrees, 14GB
- After:  13 git worktrees + 23 FS orphans (PermissionError-locked), 3.7GB
- Removed: 82 git entries (80 merged + 2 closed), -10.3GB (-74%)
- Remaining 12 keep (recent WIP, no PR yet) + 1 current branch
- 23 FS orphans cleanable after next Claude Code restart

Requires:
- FORGEJO_TOKEN env (already set via ~/.claude/settings.json)
- python 3 stdlib only (urllib + json + shutil — no jq/curl/external deps)

Usage:
  python scripts/cleanup-worktrees-aggressive.py --dry-run   # show plan
  python scripts/cleanup-worktrees-aggressive.py             # execute
  AGE_DAYS=30 python scripts/...                             # override threshold
2026-05-24 12:30:15 +03:00
..
auth feat(security): закрыть gendsgn.ru basic_auth gate (multi-user, 11 users) (#426) 2026-05-23 08:16:10 +00:00
claude-hooks chore(claude-config): align with 2026 best practices (#495) 2026-05-24 08:48:42 +00:00
bootstrap_glitchtip.sh fix(infra): bootstrap_glitchtip — \gexec instead of DO block (psql var trap) (#219) 2026-05-16 15:54:29 +00:00
bootstrap_schema_migrations.sh feat(infra): auto-apply data/sql/*.sql migrations in deploy pipeline (#150) (#151) 2026-05-15 08:06:54 +03:00
cleanup-worktrees-aggressive.py chore(claude): aggressive worktree cleanup via Forgejo PR API 2026-05-24 12:30:15 +03:00
cleanup_ghosts.py fix(worker): port objective_etl from psycopg2 → psycopg v3 2026-05-11 12:07:57 +03:00
migrate_kg_to_obsidian.py fix(worker): port objective_etl from psycopg2 → psycopg v3 2026-05-11 12:07:57 +03:00
setup-couchdb.sh feat(deploy): split obsidian stack from main + path-filtered GHA 2026-05-11 09:51:31 +03:00