Skip to content

Commit

Permalink
Swaps compare for open in worktree
Browse files Browse the repository at this point in the history
Refs #3615
  • Loading branch information
eamodio committed Sep 25, 2024
1 parent af5f8d9 commit a1f3b40
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7393,7 +7393,7 @@
"command": "gitlens.views.openInWorktree",
"title": "Open in Worktree",
"category": "GitLens",
"icon": "$(window)"
"icon": "$(empty-window)"
},
{
"command": "gitlens.views.openWorktree",
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion src/plus/launchpad/launchpadProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/views/viewCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a1f3b40

Please sign in to comment.