Skip to content

Require typed confirmation to delete branches with unmerged changes - #13

Merged
AgileIndustrialComplex merged 1 commit into
essafrom
claude/unmerged-branch-delete-confirm-0c9f13
Jul 19, 2026
Merged

AgileIndustrialComplex merged 1 commit into
essafrom
claude/unmerged-branch-delete-confirm-0c9f13

Conversation

@AgileIndustrialComplex

Copy link
Copy Markdown
Owner

Summary

  • git branch -d (non-force) silently refuses to delete a branch that isn't fully merged, so wt's mark-then-D delete flow previously just failed for such branches with no path to actually remove them.
  • gitdata.Collect now detects merge status per branch (via git branch --merged) and sets a new Item.Unmerged flag.
  • If any branch in the marked set is unmerged, confirming the existing delete screen (D → Enter) no longer deletes immediately. Instead it opens a second screen listing the unmerged branch(es) that requires typing the exact phrase "Yes, I want to remove the branch that has changes that have been unmerged." before proceeding. Esc/Ctrl-C cancels the whole batch without touching Git state.
  • Once confirmed, the batch is deleted in one pass: git branch -d for merged branches, git branch -D (force) for unmerged ones.
  • Marked sets containing only merged branches are unaffected — no extra screen, same behavior as before.

Why

wt currently offers no way at all to delete a branch with unmerged commits; the delete just errors out. This adds that capability behind deliberate friction (an exact typed phrase) so it can't happen by accident.

Test plan

  • go vet ./..., go build ./..., go test ./... all pass
  • New unit tests in internal/gitdata, internal/ui, internal/action covering merge detection, the new confirm mode (wrong phrase, exact phrase, cancel, backspace, mixed merged/unmerged batches), and the -D force-delete path
  • New end-to-end integration test (TestIntegrationDeleteUnmergedBranchRequiresForcePhrase) drives a real repo through mark → D → Enter → typed phrase → Enter via teatest and confirms git branch -D actually removes the branch
  • SPEC.md and README.md updated to document the new screen

🤖 Generated with Claude Code

`git branch -d` (non-force) silently refuses branches that aren't fully
merged, so deleting one via the mark-then-D flow previously just failed.
gitdata.Collect now detects merge status per branch (git branch --merged),
and if any marked branch is unmerged, confirming delete opens a second
screen requiring the user to type an exact phrase before the batch is
force-deleted (git branch -D for the unmerged ones, -d for the rest).
Batches with no unmerged branches are unaffected.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@AgileIndustrialComplex
AgileIndustrialComplex merged commit 86e7a29 into essa Jul 19, 2026
5 checks passed
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