Skip to content

Commit af07a44

Browse files
Copilotalexr00
andauthored
feat: add pr.pickInWorktreeFromDescription command for PR overview checkout menu
Agent-Logs-Url: https://github.com/microsoft/vscode-pull-request-github/sessions/32630df4-6da8-4847-8013-e2fb1dabc1bb Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 5f65fda commit af07a44

3 files changed

Lines changed: 29 additions & 11 deletions

File tree

package.json

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,12 @@
10191019
"category": "%command.pull.request.category%",
10201020
"icon": "$(folder-library)"
10211021
},
1022+
{
1023+
"command": "pr.pickInWorktreeFromDescription",
1024+
"title": "%command.pr.pickInWorktree.title%",
1025+
"category": "%command.pull.request.category%",
1026+
"icon": "$(folder-library)"
1027+
},
10221028
{
10231029
"command": "pr.exit",
10241030
"title": "%command.pr.exit.title%",
@@ -2094,6 +2100,10 @@
20942100
"command": "pr.pickInWorktree",
20952101
"when": "false"
20962102
},
2103+
{
2104+
"command": "pr.pickInWorktreeFromDescription",
2105+
"when": "false"
2106+
},
20972107
{
20982108
"command": "pr.exit",
20992109
"when": "github:inReviewMode"
@@ -3656,13 +3666,18 @@
36563666
"when": "webviewId == PullRequestOverview && github:checkoutMenu"
36573667
},
36583668
{
3659-
"command": "pr.checkoutOnVscodeDevFromDescription",
3669+
"command": "pr.pickInWorktreeFromDescription",
36603670
"group": "checkout@1",
3671+
"when": "webviewId == PullRequestOverview && github:checkoutMenu && !isWeb"
3672+
},
3673+
{
3674+
"command": "pr.checkoutOnVscodeDevFromDescription",
3675+
"group": "checkout@2",
36613676
"when": "webviewId == PullRequestOverview && github:checkoutMenu"
36623677
},
36633678
{
36643679
"command": "pr.checkoutOnCodespacesFromDescription",
3665-
"group": "checkout@2",
3680+
"group": "checkout@3",
36663681
"when": "webviewId == PullRequestOverview && github:checkoutMenu"
36673682
},
36683683
{

src/commands.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,17 @@ export function registerCommands(
959959
}),
960960
);
961961

962+
context.subscriptions.push(vscode.commands.registerCommand('pr.pickInWorktreeFromDescription', async (ctx: BaseContext | undefined) => {
963+
if (!ctx) {
964+
return vscode.window.showErrorMessage(vscode.l10n.t('No pull request context provided for checkout.'));
965+
}
966+
const resolved = await resolvePr(ctx);
967+
if (!resolved) {
968+
return vscode.window.showErrorMessage(vscode.l10n.t('Unable to resolve pull request for checkout.'));
969+
}
970+
return vscode.commands.executeCommand('pr.pickInWorktree', resolved.pr);
971+
}));
972+
962973
context.subscriptions.push(vscode.commands.registerCommand('pr.checkoutOnVscodeDevFromDescription', async (context: BaseContext | undefined) => {
963974
if (!context) {
964975
return vscode.window.showErrorMessage(vscode.l10n.t('No pull request context provided for checkout.'));

webviews/components/header.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ interface CheckoutButtonProps {
306306
}
307307

308308
const CheckoutButton: React.FC<CheckoutButtonProps> = ({ isCurrentlyCheckedOut, isIssue, doneCheckoutBranch, owner, repo, number }) => {
309-
const { exitReviewMode, checkout, checkoutInWorktree, openChanges } = useContext(PullRequestContext);
309+
const { exitReviewMode, checkout, openChanges } = useContext(PullRequestContext);
310310
const [isBusy, setBusy] = useState(false);
311311

312312
const onClick = async (command: string) => {
@@ -317,9 +317,6 @@ const CheckoutButton: React.FC<CheckoutButtonProps> = ({ isCurrentlyCheckedOut,
317317
case 'checkout':
318318
await checkout();
319319
break;
320-
case 'checkoutInWorktree':
321-
await checkoutInWorktree();
322-
break;
323320
case 'exitReviewMode':
324321
await exitReviewMode();
325322
break;
@@ -360,11 +357,6 @@ const CheckoutButton: React.FC<CheckoutButtonProps> = ({ isCurrentlyCheckedOut,
360357
value: '',
361358
action: () => onClick('checkout')
362359
});
363-
actions.push({
364-
label: 'Checkout in Worktree',
365-
value: '',
366-
action: () => onClick('checkoutInWorktree')
367-
});
368360
}
369361

370362
actions.push({

0 commit comments

Comments
 (0)