Files
kandev/apps/backend/internal/worktree
João Salavisa 62ddfd4d17 refactor(worktree): split manager.go into per-concern files (#1055)
The Manager type owned creation, removal, state queries, and git helpers
in a single 1,615-line file (2x the lint threshold). Decompose into five
files within the same package, preserving the Manager public API and all
existing test coverage:

  - manager.go         struct, interfaces, NewManager, repo locks
  - manager_lifecycle  Create, recreate, git worktree add paths
  - manager_state      cache, persistence, Get* lookups, IsValid
  - manager_cleanup    RemoveByID, setup/cleanup scripts, dir removal
  - manager_git        branch inspection, non-interactive git, pull sync

Extract four helpers to satisfy the new-code lint baseline that fires on
moved-but-unchanged complexity hot-spots:

  - tryReuseExisting + resolveBaseRefWithFallback split Create (cyclo 21)
  - gitAddWorktreeForRecreate trims recreate below 80 lines
  - retryFetchAsRemoteTrackingRef flattens fetchBranchToLocal nesting

No behavior change; all existing internal/worktree tests pass unchanged.

Co-authored-by: Kandev Agent <agent@kandev.dev>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-28 23:57:11 +01:00
..