From a1f3b4037e097d5a8e32a88aa263bd15cb14581e Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Wed, 25 Sep 2024 02:12:22 -0400 Subject: [PATCH] Swaps compare for open in worktree Refs #3615 --- package.json | 30 ++++++++++++------------- src/plus/launchpad/launchpadProvider.ts | 4 +++- src/views/viewCommands.ts | 6 ++++- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 790a5f88ea28c..aad9b424701e2 100644 --- a/package.json +++ b/package.json @@ -7393,7 +7393,7 @@ "command": "gitlens.views.openInWorktree", "title": "Open in Worktree", "category": "GitLens", - "icon": "$(window)" + "icon": "$(empty-window)" }, { "command": "gitlens.views.openWorktree", @@ -14606,36 +14606,36 @@ "when": "viewItem =~ /gitlens:(pullrequest\\b(?=.*?\\b\\+refs\\b)|launchpad:item\\b(?=.*?\\b\\+pr\\b))/ && config.multiDiffEditor.experimental.enabled", "group": "inline@2" }, - { - "command": "gitlens.views.openPullRequestComparison", - "when": "viewItem =~ /gitlens:(pullrequest\\b(?=.*?\\b\\+refs\\b)|launchpad:item\\b(?=.*?\\b\\+pr\\b))/", - "group": "inline@3" - }, { "command": "gitlens.openPullRequestOnRemote", "when": "viewItem =~ /gitlens:(pullrequest\\b|launchpad:item\\b(?=.*?\\b\\+pr\\b))/", - "group": "inline@99", + "group": "inline@98", "alt": "gitlens.copyRemotePullRequestUrl" }, { - "command": "gitlens.views.openPullRequestChanges", - "when": "!listMultiSelection && viewItem =~ /gitlens:(pullrequest\\b(?=.*?\\b\\+refs\\b)|launchpad:item\\b(?=.*?\\b\\+pr\\b))/ && config.multiDiffEditor.experimental.enabled", - "group": "1_gitlens_actions@1" + "command": "gitlens.views.openInWorktree", + "when": "!listMultiSelection && viewItem =~ /gitlens:(pullrequest\\b|launchpad:item\\b(?=.*?\\b\\+pr\\b))/", + "group": "inline@99" }, { "command": "gitlens.views.openPullRequest", "when": "!listMultiSelection && gitlens:action:openPullRequest > 1 && viewItem =~ /gitlens:pullrequest\\b/", - "group": "1_gitlens_actions@98" + "group": "1_gitlens_actions@1" }, { - "command": "gitlens.openPullRequestOnRemote", + "command": "gitlens.views.openInWorktree", "when": "!listMultiSelection && viewItem =~ /gitlens:(pullrequest\\b|launchpad:item\\b(?=.*?\\b\\+pr\\b))/", - "group": "1_gitlens_actions@99" + "group": "1_gitlens_actions@2" }, { - "command": "gitlens.views.openInWorktree", + "command": "gitlens.views.openPullRequestChanges", + "when": "!listMultiSelection && viewItem =~ /gitlens:(pullrequest\\b(?=.*?\\b\\+refs\\b)|launchpad:item\\b(?=.*?\\b\\+pr\\b))/ && config.multiDiffEditor.experimental.enabled", + "group": "2_gitlens_quickopen@1" + }, + { + "command": "gitlens.openPullRequestOnRemote", "when": "!listMultiSelection && viewItem =~ /gitlens:(pullrequest\\b|launchpad:item\\b(?=.*?\\b\\+pr\\b))/", - "group": "1_gitlens_actions@100" + "group": "2_gitlens_quickopen@2" }, { "command": "gitlens.showInCommitGraph", diff --git a/src/plus/launchpad/launchpadProvider.ts b/src/plus/launchpad/launchpadProvider.ts index 05c5f0e4aa884..89dcf93c1736d 100644 --- a/src/plus/launchpad/launchpadProvider.ts +++ b/src/plus/launchpad/launchpadProvider.ts @@ -518,6 +518,7 @@ export class LaunchpadProvider implements Disposable { async openInGraph(item: LaunchpadItem) { const deepLinkUrl = this.getItemBranchDeepLink(item); if (deepLinkUrl == null) return; + await this.container.deepLinks.processDeepLinkUri(deepLinkUrl, false); } @@ -526,8 +527,9 @@ export class LaunchpadProvider implements Disposable { } private getItemBranchDeepLink(item: LaunchpadItem, action?: DeepLinkActionType): Uri | undefined { - if (item.type !== 'pullrequest' || item.headRef == null || item.repoIdentity?.remote?.url == null) + if (item.type !== 'pullrequest' || item.headRef == null || item.repoIdentity?.remote?.url == null) { return undefined; + } const branchName = action == null && item.openRepository?.localBranch?.current diff --git a/src/views/viewCommands.ts b/src/views/viewCommands.ts index 42910011ebe9e..3d28b718283f6 100644 --- a/src/views/viewCommands.ts +++ b/src/views/viewCommands.ts @@ -792,11 +792,15 @@ export class ViewCommands { skipWorktreeConfirmations: true, }, }); - } else if (node.is('pullrequest') || node.is('launchpad-item')) { + } + + if (node.is('pullrequest') || node.is('launchpad-item')) { const pr = node.pullRequest; if (pr?.refs?.head == null) return Promise.resolve(); + const repoIdentity = getRepositoryIdentityForPullRequest(pr); if (repoIdentity.remote.url == null) return Promise.resolve(); + const deepLink = getPullRequestBranchDeepLink( this.container, pr.refs.head.branch,