fix(worktree): lifecycle ordering + echo shell-safety#12
Merged
Conversation
Two bugs found dogfooding the worktree plugin (PR #10) on the pool-probe fix: 1. echo backticks → shell command substitution. worktree_sh_start / worktree_sh_pr embedded `worktree pr` / `worktree start` in echo strings; when the echo runs in the shell the backticks trigger command substitution → stray "worktree: command not found". Fixed: backticks removed. 2. merge/finish branch-delete ordering. worktree_sh_merge ran `gh pr merge --delete-branch`, but the worktree still has the local branch checked out, so the local-branch delete fails ("cannot delete branch … used by worktree"). Fixed: merge does `gh pr merge --merge` only (remote merge); branch cleanup (local + remote) moves to finish, which runs it AFTER `git worktree remove` frees the branch — `git branch -d` (safe form: refuses an unmerged branch) + `git push origin --delete` (best-effort). Correct lifecycle: pr → merge → finish (remove worktree + clean branch local & remote). Verified: wilson build OK; wilson test 23/23; test_worktree.hexa selftest ok (merge no longer asserts --delete-branch; finish asserts branch -d + push --delete). Done via the worktree plugin itself (start→pr→merge→finish) — the tool fixing itself. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two bugs found dogfooding the worktree plugin: (1) echo backticks triggered shell command substitution → stray 'worktree: command not found'; (2) merge --delete-branch failed the local-branch delete (worktree still holds it). Fixed: merge does remote merge only; branch cleanup (local+remote) moves to finish after the worktree is removed. wilson test 23/23; selftest ok. Done via the worktree plugin itself.