Skip to content

feat(worktree): delete branches after merged cleanup - #462

Open
christso wants to merge 1 commit into
mainfrom
fix/worktree-delete-merged-branches
Open

feat(worktree): delete branches after merged cleanup#462
christso wants to merge 1 commit into
mainfrom
fix/worktree-delete-merged-branches

Conversation

@christso

@christso christso commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add remove --merged for post-merge cleanup of both the linked worktree and its local branch
  • preserve normal removal for unfinished branches and existing dirty-worktree protection
  • resolve the checked-out branch before removal and delete it through the shared Git directory, including after squash merges
  • document the explicit merge-confirmation contract and completion checks
  • add real temporary-repository regression coverage

Verification

  • bun test tests/unit/scripts/worktree.test.ts — 2 passed
  • bash -n plugins/engineering/skills/worktree/scripts/worktree.sh
  • bun run lint
  • bun run typecheck
  • bun test — 1462 passed, 5 skipped, 0 failed
  • final code review — no PR-blocking findings

Manual E2E

  1. Initialized a temporary Git repository on main and configured repository-local test identity.
  2. Ran the packaged script with add feat/merged main and a temporary WORKTREE_ROOT.
  3. Committed a feature file in the linked worktree.
  4. Ran git merge --squash feat/merged and committed the squash on main.
  5. Confirmed git merge-base --is-ancestor feat/merged main returned nonzero, exercising the squash-merge case rather than ordinary ancestry.
  6. Ran remove --merged feat/merged through the packaged script.
  7. Confirmed the worktree directory was absent, git worktree list --porcelain no longer registered it, and git branch --list feat/merged printed nothing.

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