Repository navigation
fix(switch): keep --path and --execute in the leftover-branch hint - #4841
Merged
Merged
Conversation
When wt switch --create failed after git worktree add -b wrote the branch, the hint suggested a bare `wt switch <branch>`, dropping --path, --execute, and trailing args. WorktreeCreationFailed comes from execute_switch, whose errors weren't wrapped in WithSwitchSuggestion the way plan_switch's are. Wrap that variant and apply the context when rendering its hint. Closes #4839
1 task
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.
When
wt switch --createfailed aftergit worktree add -bhad already written the branch, the leftover-branch hint suggested a barewt switch <branch>. Following it created the worktree at theworktree-pathtemplate location instead of the--pathgiven, and skipped the--executecommand.WorktreeCreationFailedis raised inexecute_switch, whose errors weren't wrapped inWithSwitchSuggestionthe wayplan_switch's are, so the hint had no flags to draw on.SwitchPipeline::runnow wraps that variant with the switch context, and the hint applies it. The hint becomes e.g.wt switch stranded --path=blocked/stranded --execute='echo hi' -- extra.--createis not in the context, so it stays out of the suggestion, which is correct now that the branch exists. Otherexecute_switcherrors pass through unchanged, so their context chains and downcasts are untouched.test_switch_create_leftover_branch_hint_keeps_flagsfails onmain(the hint ends atwt switch stranded) and passes with this change. The existing leftover-branch test still covers the no-flags form.#4705 adds a hint for pre-start failures on the same
execute_switchpath. If it suggests awt switchcommand, it can reuse this wrapping.Closes #4839 — automated triage