Skip to content

Fix pm rm leaking worktree dirs on slot release#816

Draft
claude[bot] wants to merge 1 commit into
mainfrom
fix/pm-rm-worktree-leak-dco
Draft

Fix pm rm leaking worktree dirs on slot release#816
claude[bot] wants to merge 1 commit into
mainfrom
fix/pm-rm-worktree-leak-dco

Conversation

@claude

@claude claude Bot commented Jun 24, 2026

Copy link
Copy Markdown

Requested by Bradley Axen · Slack thread

Before / After (plain language, what a user sees): Before, running pm rm <project> removed the project from pm's state but left the git worktree directory under .pm/pool/repo--N on disk (and a dangling entry in git worktree list), so stale worktrees accumulated over time. After, pm rm (and the stale-state cleanup paths in pm new / pm status) fully remove the worktree from disk and from git's worktree metadata.

How: Wire up the previously-dead remove_slot_worktree helper into the shared pool::release_project path. It runs git worktree remove --force (falling back to git worktree prune) against the repo's bare clone, then force-removes the dir if git left it behind. Removal is best-effort so a manually-deleted slot doesn't make pm rm error; slot.branch is now cleared alongside slot.owner. Removed two #[allow(dead_code)] markers (pool.rs, git.rs). pm cleanup is read-only and inherits the fix transitively. Note: there is no existing test covering the pool-release path; verified via cargo test (workspace green) plus a manual smoke test (add → rm leaves the pool dir empty and git worktree list clean; a pre-deleted slot exits 0).


Generated by Claude Code

Wire the previously-dead remove_slot_worktree helper into the shared
pool::release_project path so releasing a project's slots removes the
worktree from disk and from git's worktree metadata, not just from pm
state. Removal is best-effort so a manually-deleted slot doesn't make
pm rm error; slot.branch is now cleared alongside slot.owner. Removed
two now-unnecessary #[allow(dead_code)] markers.

Signed-off-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant