feat!: make exact path the default, add --append-branch flag #11
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.
Summary
This PR includes two important improvements to the
gh worktree prcommand:1. Fix: Checkout correct PR branch (bug fix)
This fixes a critical bug in the original implementation. The command was not checking out the actual PR branch - instead it was creating a new local branch. This meant users weren't actually getting the PR's code when running
gh worktree pr.Before (broken):
gh worktree pr 123→ Creates new branch named after the pathgit worktree add <path>(missing branch parameter)After (fixed):
gh worktree pr 123→ Checks out the actual PR branchgit worktree add <path> <branch>2. Enhancement: Use exact paths by default
Changes the default behavior when providing a custom path to use the exact path specified, rather than appending the branch name as a subdirectory. The previous behavior is still available via the new
--append-branchflag.Before:
gh worktree pr 123 ../pr-123→ Creates at../pr-123/branch-nameAfter:
gh worktree pr 123 ../pr-123→ Creates at../pr-123(exact path)gh worktree pr 123 ../pr-123 --append-branch→ Creates at../pr-123/branch-name(old behavior)Changes
worktree.Add()to pass branch name togit worktree addcommand--append-branchflag to preserve the old subdirectory behaviorAddWithOptions()function to handle both behaviorsTesting
Both fixes have been tested locally:
--append-branchflagBreaking Change
--append-branchflag to maintain the previous behavior.However, the bug fix for branch checkout is purely beneficial - it makes the tool actually work as intended.