feat: support git worktrees when checking out PRs#794
Open
sideshowbarker wants to merge 1 commit intodlvhdr:mainfrom
Open
feat: support git worktrees when checking out PRs#794sideshowbarker wants to merge 1 commit intodlvhdr:mainfrom
sideshowbarker wants to merge 1 commit intodlvhdr:mainfrom
Conversation
ab570b0 to
dbfac76
Compare
dbfac76 to
1a35305
Compare
1a35305 to
ec7387d
Compare
Fixes dlvhdr#544 Add a new worktreePaths config key that enables git worktree-based checkouts. When a repository matches a worktreePaths entry, pressing checkout (C/Space) creates a worktree subdirectory named after the PR branch — rather than switching branches in place. On success, the worktree path is copied to the clipboard. If the worktree already exists, Dash skips creation and copies the path. If “gh pr checkout” fails inside a new worktree, the worktree is automatically cleaned up. This change also extracts/consolidates the PR-checkout code into a shared common.CheckoutPR() function used by both the PR dashboard and Notification dashboard — avoiding code duplication.
ec7387d to
0e14b8f
Compare
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.
Add a new
worktreePathsconfig key that enables linked worktree checkouts. When a repository matches aworktreePathsentry, pressing C or Space (checkout) creates a linked worktree named after the PR branch — rather than switching branches in the clone directory. Fixes #544.How it works
repoPaths→ the clone directory wheregit worktree addgets runworktreePaths→ a worktrees directory where linked worktrees are created as subdirectories, one per PR branchBoth must be configured for the same repository or template pattern. Example:
Behavior
repoPaths: Shows an error explaining that both settings are requiredOn success, the linked-worktree path is copied to the clipboard.
Note
This all also works in bare repo worktree workflows (where even the main branch is a linked worktree), as long as
repoPathspoints not to a.baredirectory but to an actual clone directory containing a.bare|.gitdirectory.Code/test/docs/config notes
common.CheckoutPR()function used by both the PR and Notification dashboards (previously duplicated)RunCommandFuncnow captures stderr from gh/git)worktreePaths