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:
@@ -147,8 +147,8 @@ var polecatGCCmd = &cobra.Command{
|
||||
Long: `Garbage collect stale polecat branches in a rig.
|
||||
|
||||
Polecats use unique timestamped branches (polecat/<name>-<timestamp>) to
|
||||
prevent drift issues. Over time, these branches accumulate as polecats
|
||||
are recreated.
|
||||
prevent drift issues. Over time, these branches accumulate when stale
|
||||
polecats are repaired.
|
||||
|
||||
This command removes orphaned branches:
|
||||
- Branches for polecats that no longer exist
|
||||
|
||||
@@ -76,7 +76,7 @@ func SpawnPolecatForSling(rigName string, opts SlingSpawnOptions) (*SpawnedPolec
|
||||
}
|
||||
fmt.Printf("Allocated polecat: %s\n", polecatName)
|
||||
|
||||
// Check if polecat already exists (shouldn't, since we allocated fresh)
|
||||
// Check if polecat already exists (shouldn't happen - indicates stale state needing repair)
|
||||
existingPolecat, err := polecatMgr.Get(polecatName)
|
||||
|
||||
// Build add options with hook_bead set atomically at spawn time
|
||||
@@ -85,7 +85,7 @@ func SpawnPolecatForSling(rigName string, opts SlingSpawnOptions) (*SpawnedPolec
|
||||
}
|
||||
|
||||
if err == nil {
|
||||
// Exists - recreate with fresh worktree
|
||||
// Stale state: polecat exists despite fresh name allocation - repair it
|
||||
// Check for uncommitted work first
|
||||
if !opts.Force {
|
||||
pGit := git.NewGit(existingPolecat.ClonePath)
|
||||
@@ -95,9 +95,9 @@ func SpawnPolecatForSling(rigName string, opts SlingSpawnOptions) (*SpawnedPolec
|
||||
polecatName, workStatus.String())
|
||||
}
|
||||
}
|
||||
fmt.Printf("Recreating polecat %s with fresh worktree...\n", polecatName)
|
||||
if _, err = polecatMgr.RecreateWithOptions(polecatName, opts.Force, addOpts); err != nil {
|
||||
return nil, fmt.Errorf("recreating polecat: %w", err)
|
||||
fmt.Printf("Repairing stale polecat %s with fresh worktree...\n", polecatName)
|
||||
if _, err = polecatMgr.RepairWorktreeWithOptions(polecatName, opts.Force, addOpts); err != nil {
|
||||
return nil, fmt.Errorf("repairing stale polecat: %w", err)
|
||||
}
|
||||
} else if err == polecat.ErrPolecatNotFound {
|
||||
// Create new polecat
|
||||
|
||||
Reference in New Issue
Block a user