From ab31b2b397a40b2723d73ca4613ee926135e7329 Mon Sep 17 00:00:00 2001 From: Ramin Tadayon <67011668+axosoft-ramint@users.noreply.github.com> Date: Tue, 4 Apr 2023 13:18:21 -0700 Subject: [PATCH] Add publish context menu action to local branches in graph (#2619) --- package.json | 16 ++++++++++++++++ src/plus/webviews/graph/graphWebview.ts | 11 +++++++++++ 2 files changed, 27 insertions(+) diff --git a/package.json b/package.json index 4d2e6a7..384133c 100644 --- a/package.json +++ b/package.json @@ -6975,6 +6975,13 @@ "enablement": "!operationInProgress" }, { + "command": "gitlens.graph.publishBranch", + "title": "Publish Branch", + "category": "GitLens", + "icon": "$(cloud-upload)", + "enablement": "!operationInProgress" + }, + { "command": "gitlens.graph.rebaseOntoBranch", "title": "Rebase Current Branch onto Branch...", "category": "GitLens", @@ -9181,6 +9188,10 @@ "when": "false" }, { + "command": "gitlens.graph.publishBranch", + "when": "false" + }, + { "command": "gitlens.graph.rebaseOntoBranch", "when": "false" }, @@ -11936,6 +11947,11 @@ "alt": "gitlens.copyRemoteBranchUrl" }, { + "command": "gitlens.graph.publishBranch", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && webviewItem =~ /gitlens:branch\\b(?!.*?\\b\\+remote\\b)(?!.*?\\b\\+tracking\\b)/", + "group": "8_gitlens_actions@13" + }, + { "command": "gitlens.graph.cherryPick", "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && webviewItem =~ /gitlens:commit\\b(?!.*?\\b\\+current\\b)/", "group": "1_gitlens_actions@1" diff --git a/src/plus/webviews/graph/graphWebview.ts b/src/plus/webviews/graph/graphWebview.ts index b4d3298..0de3562 100644 --- a/src/plus/webviews/graph/graphWebview.ts +++ b/src/plus/webviews/graph/graphWebview.ts @@ -308,6 +308,7 @@ export class GraphWebviewProvider implements WebviewProvider { registerCommand('gitlens.graph.push', this.push, this), registerCommand('gitlens.graph.pull', this.pull, this), registerCommand('gitlens.graph.fetch', this.fetch, this), + registerCommand('gitlens.graph.publishBranch', this.publishBranch, this), registerCommand('gitlens.graph.switchToAnotherBranch', this.switchToAnother, this), registerCommand('gitlens.graph.createBranch', this.createBranch, this), @@ -2018,6 +2019,16 @@ export class GraphWebviewProvider implements WebviewProvider { } @debug() + private publishBranch(item?: GraphItemContext) { + if (isGraphItemRefContext(item, 'branch')) { + const { ref } = item.webviewItemValue; + return RepoActions.push(ref.repoPath, undefined, ref); + } + + return Promise.resolve(); + } + + @debug() private rebase(item?: GraphItemContext) { const ref = this.getGraphItemRef(item); if (ref == null) return Promise.resolve();