Add checkout pull request in worktree option#8513
Conversation
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
… naming Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
…l execution Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
src/commands.ts
Outdated
| const openAction = vscode.l10n.t('Open in New Window'); | ||
| const result = await vscode.window.showInformationMessage( | ||
| vscode.l10n.t('Worktree created for Pull Request #{0}', pullRequestModel.number), | ||
| openAction | ||
| ); |
There was a problem hiding this comment.
@copilot This should happen after the progress is finished, otherwise the progress reports until this info is acked.
There was a problem hiding this comment.
Moved the info message to after the progress completes in commit ad74445. The showInformationMessage call now happens after withProgress resolves.
src/commands.ts
Outdated
| try { | ||
| await repositoryToUse.fetch({ remote: remoteName, ref: branchName }); | ||
| } catch (e) { | ||
| const errorMessage = e instanceof Error ? e.message : String(e); | ||
| Logger.appendLine(`Failed to fetch branch ${branchName}: ${errorMessage}`, logId); | ||
| // Continue even if fetch fails - the branch might already be available locally | ||
| } | ||
|
|
||
| // Ask user for worktree location | ||
| const repoRootPath = repositoryToUse.rootUri.fsPath; | ||
| const parentDir = pathLib.dirname(repoRootPath); | ||
| const defaultWorktreePath = pathLib.join(parentDir, `pr-${pullRequestModel.number}`); | ||
|
|
||
| const worktreeUri = await vscode.window.showSaveDialog({ | ||
| defaultUri: vscode.Uri.file(defaultWorktreePath), | ||
| title: vscode.l10n.t('Select Worktree Location'), | ||
| saveLabel: vscode.l10n.t('Create Worktree'), | ||
| }); |
…after progress Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
src/commands.ts
Outdated
| const remoteName = pullRequestModel.remote.remoteName; | ||
|
|
||
| // Run fetch and worktree location selection in parallel | ||
| const [, worktreeUri] = await Promise.all([ |
There was a problem hiding this comment.
Restructured the code in commit 766d8a0. The progress now starts before the fetch operation and covers both fetch and worktree creation. The dialog for selecting the worktree location is shown before the progress starts.
… scope Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
|
I know that initial request was about context menu, but shouldn't it be added to |
|
@IllusionMH that seems fair. @copilot address this:
|
Added the "Checkout in Worktree" option to the CheckoutButton dropdown in the PR Description view in commit fa08fb7. The option appears in the dropdown when the PR is not currently checked out, alongside the existing "Checkout" and "Open Changes" options. |
This PR adds a new "Checkout Pull Request in Worktree" option that allows users to check out a PR branch in a git worktree instead of the main working directory. This enables reviewing colleagues' PRs without having to commit current work, stash changes, or deal with merge conflicts.
Summary
The worktree checkout option is available in two places:
Implementation Details
createWorktreeAPI!isWebwhen clauseOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.