refactor: Rename RecreateWithOptions to RepairWorktreeWithOptions

Clarify that this operation is for stale state recovery, not normal recycling:

- Recreate → RepairWorktree
- RecreateWithOptions → RepairWorktreeWithOptions
- Updated comments to explain this handles reconciliation when AllocateName
  returns a name that already exists (stale state needing repair)
- Updated polecat_spawn.go output: Recreating → Repairing stale
- Updated gc command help text for consistency

The function is useful for atomic hook_bead setting during repair, so kept
rather than replacing with Remove + Add.

Fixes gt-l0lok

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
dinki
2026-01-04 14:25:53 -08:00
committed by Steve Yegge
parent b732eb075b
commit 871410f157
3 changed files with 20 additions and 16 deletions

View File

@@ -385,20 +385,24 @@ func (m *Manager) ReleaseName(name string) {
_ = m.namePool.Save() // non-fatal: state file update
}
// Recreate removes an existing polecat and creates a fresh worktree.
// This ensures the polecat starts with the latest code from the base branch.
// The name is preserved (not released to pool) since we're recreating immediately.
// RepairWorktree repairs a stale polecat by removing it and creating a fresh worktree.
// This is NOT for normal operation - it handles reconciliation when AllocateName
// returns a name that unexpectedly already exists (stale state recovery).
//
// The polecat starts with the latest code from origin/<default-branch>.
// The name is preserved (not released to pool) since we're repairing immediately.
// force controls whether to bypass uncommitted changes check.
//
// Branch naming: Each recreation gets a unique branch (polecat/<name>-<timestamp>).
// Branch naming: Each repair gets a unique branch (polecat/<name>-<timestamp>).
// Old branches are left for garbage collection - they're never pushed to origin.
func (m *Manager) Recreate(name string, force bool) (*Polecat, error) {
return m.RecreateWithOptions(name, force, AddOptions{})
func (m *Manager) RepairWorktree(name string, force bool) (*Polecat, error) {
return m.RepairWorktreeWithOptions(name, force, AddOptions{})
}
// RecreateWithOptions removes an existing polecat and creates a fresh worktree with options.
// This allows setting hook_bead atomically at recreation time.
func (m *Manager) RecreateWithOptions(name string, force bool, opts AddOptions) (*Polecat, error) {
// RepairWorktreeWithOptions repairs a stale polecat and creates a fresh worktree with options.
// This is NOT for normal operation - see RepairWorktree for context.
// Allows setting hook_bead atomically at repair time.
func (m *Manager) RepairWorktreeWithOptions(name string, force bool, opts AddOptions) (*Polecat, error) {
if !m.exists(name) {
return nil, ErrPolecatNotFound
}