Skip to content

fix(stack): release checked-out landed branches#30

Closed
aryasaatvik wants to merge 1 commit into
kitlangton:mainfrom
aryasaatvik:pr/release-checked-out-landed-branches
Closed

fix(stack): release checked-out landed branches#30
aryasaatvik wants to merge 1 commit into
kitlangton:mainfrom
aryasaatvik:pr/release-checked-out-landed-branches

Conversation

@aryasaatvik

Copy link
Copy Markdown
Contributor

Summary

stack merge --apply and stack merge --auto can complete the hosted merge, then fail during local cleanup when the landed branch is checked out in another worktree. Git refuses to delete a branch that is checked out elsewhere, which leaves the stack half-landed locally even though the PR has merged.

This PR adds an explicit release step for clean sibling worktrees that own the landed branch, and fails before hosted mutation when that target worktree is dirty.

Changes

  • Add Git.release(branch) to detach a clean sibling worktree at HEAD when it owns the landed branch.
  • Reuse the dirty worktree preflight so dirty target owners fail before merge/auto-merge starts.
  • Call release(target) before drop(target) during post-merge local cleanup.
  • Add regression coverage for clean release, no-op release, --apply and --auto cleanup, and dirty target refusal.

Tests

  • bun run test
  • bun run typecheck
  • bun run format:check
  • bun run lint
  • bun run build
  • bun run package:smoke

Detach clean sibling worktrees that own a just-landed branch before deleting the local branch during stack merge cleanup.

Dirty target owners now fail before hosted merge, matching descendant repair preflight behavior.
@aryasaatvik

Copy link
Copy Markdown
Contributor Author

Closing this in favor of the consolidated PR #31.

@kitlangton kitlangton reopened this Jun 30, 2026
kitlangton pushed a commit that referenced this pull request Jun 30, 2026
When `stack merge --apply` or `stack merge --auto` lands a branch
that is checked out in another worktree, Git refuses to delete it,
leaving the stack half-landed locally. Add `Git.release(branch)` to
detach a clean sibling worktree at HEAD before deleting the landed
branch, and fail before hosted mutation when that worktree is dirty.
@kitlangton

Copy link
Copy Markdown
Owner

Merged directly to main (the SKILL.md conflict from the skill simplification prevented a clean squash-merge through GitHub). The commit preserves authorship. Thanks @aryasaatvik!

@kitlangton kitlangton closed this Jun 30, 2026
kitlangton added a commit that referenced this pull request Jun 30, 2026
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.

2 participants