Prune: delete merged branches and offer to force dirty worktrees #56

Merged
pedromcaraujo merged 1 commit from prune-merged-branches into main 2026-11-09 10:44:47 +00:00

Prune only closed clean worktrees and always kept branches. In #nixos there were no worktrees at all, just 28 leftover local branches (shown as reopenable in the Create worktree step), so Prune said "No clean worktrees" and did nothing.

  • After closing worktrees, Prune now also deletes local branches with no checkout left that are merged into the main checkout's HEAD. That covers fast-forward and squash/rebase merges, which are matched by patch id with git cherry. Unmerged branches are never deleted. Each delete is guarded by the sha that was checked, so a branch that moved in the meantime is kept.
  • /worktrees/prune takes force. If any worktrees have uncommitted changes, the launcher asks separately ("Remove them anyway? Those changes are lost") before passing it.
  • The confirm dialog lists the worktrees to close and the branches to delete. The current session and a Claude that is mid-turn are still always kept.
  • README, shell help and the palette label are updated.

Test plan

  • Sidecar on a scratch clone of nixos with clean, dirty and unmerged-commit worktrees: the dry run, the force dry run and a real run delete the merged branches (27 of the 28) and keep upload-forge, the unmerged worktree's branch and the dirty worktree when not forced
  • index.html script passes a JS syntax check
  • After deploy: Prune in #nixos lists the merged branches and leaves upload-forge
  • The prompt for worktrees with uncommitted changes appears, and Cancel keeps them
Prune only closed *clean* worktrees and always kept branches. In #nixos there were no worktrees at all, just 28 leftover local branches (shown as reopenable in the Create worktree step), so Prune said "No clean worktrees" and did nothing. - After closing worktrees, Prune now also deletes local branches with no checkout left that are merged into the main checkout's HEAD. That covers fast-forward and squash/rebase merges, which are matched by patch id with `git cherry`. Unmerged branches are never deleted. Each delete is guarded by the sha that was checked, so a branch that moved in the meantime is kept. - `/worktrees/prune` takes `force`. If any worktrees have uncommitted changes, the launcher asks separately ("Remove them anyway? Those changes are lost") before passing it. - The confirm dialog lists the worktrees to close and the branches to delete. The current session and a Claude that is mid-turn are still always kept. - README, shell help and the palette label are updated. ## Test plan - [x] Sidecar on a scratch clone of nixos with clean, dirty and unmerged-commit worktrees: the dry run, the `force` dry run and a real run delete the merged branches (27 of the 28) and keep `upload-forge`, the unmerged worktree's branch and the dirty worktree when not forced - [x] `index.html` script passes a JS syntax check - [ ] After deploy: Prune in #nixos lists the merged branches and leaves `upload-forge` - [ ] The prompt for worktrees with uncommitted changes appears, and Cancel keeps them
Prune: delete merged branches and offer to force dirty worktrees
All checks were successful
CI / check (pull_request) Successful in 18s
1a3edede33
Prune only closed clean worktrees and always kept branches, so a channel with
no worktrees but many leftover branches (listed as reopenable in the Create
worktree step) just reported "No clean worktrees".

- After closing worktrees, delete local branches with no checkout left that
  are merged into the main checkout's HEAD: fast-forward, or squash/rebase
  merged (matched by patch id via `git cherry`). Unmerged branches are kept.
  Deletion is guarded by the checked sha, so a branch that moved is kept.
- `/worktrees/prune` takes `force` to also remove worktrees with uncommitted
  changes; the launcher asks separately before using it.
- README, shell help and palette label updated.
pedromcaraujo deleted branch prune-merged-branches 2026-11-09 10:44:47 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pedromcaraujo/forge!56
No description provided.