fix(polecat): ensure nuke fully removes worktrees and branches
Two issues fixed: 1. Worktree directory cleanup used os.Remove() which only removes empty directories. Changed to os.RemoveAll() to clean up untracked files left behind by git worktree remove (overlay files, .beads/, etc.) 2. Branch deletion hardcoded mayor/rig but worktrees are created from .repo.git when using bare repo architecture. Now checks for bare repo first to match where the branch was created. Fixes: gt-6ab3cm Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
beads/crew/emma
parent
d8bb9a9ba9
commit
0cc4867ad7
@@ -1203,8 +1203,15 @@ func runPolecatNuke(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
// Step 4: Delete branch (if we know it)
|
||||
// Use bare repo if it exists (matches where worktree was created), otherwise mayor/rig
|
||||
if branchToDelete != "" {
|
||||
repoGit := git.NewGit(filepath.Join(p.r.Path, "mayor", "rig"))
|
||||
var repoGit *git.Git
|
||||
bareRepoPath := filepath.Join(p.r.Path, ".repo.git")
|
||||
if info, err := os.Stat(bareRepoPath); err == nil && info.IsDir() {
|
||||
repoGit = git.NewGitWithDir(bareRepoPath, "")
|
||||
} else {
|
||||
repoGit = git.NewGit(filepath.Join(p.r.Path, "mayor", "rig"))
|
||||
}
|
||||
if err := repoGit.DeleteBranch(branchToDelete, true); err != nil {
|
||||
// Non-fatal - branch might already be gone
|
||||
fmt.Printf(" %s branch delete: %v\n", style.Dim.Render("○"), err)
|
||||
|
||||
Reference in New Issue
Block a user