Skip to content

Commit

Permalink
Adds publish repository command
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Feb 28, 2021
1 parent 4a6d438 commit 1e0bcfa
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- _Toggles the file heatmap_
- _Toggles the file changes since before the commit_
- _Toggles the file changes from the commit_
- Adds _Publish Repository_ command (`gitlens.publishRepository`) to publish the repository to a remote provider
- Adds supported remote types in README — thanks to [PR #1371](https://github.com/eamodio/vscode-gitlens/pull/1371) by Vladislav Guleaev ([@vguleaev](https://github.com/vguleaev))

### Changed
Expand Down
17 changes: 16 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3807,6 +3807,12 @@
"category": "GitLens",
"icon": "$(cloud-upload)"
},
{
"command": "gitlens.views.publishRepository",
"title": "Publish Repository",
"category": "GitLens",
"icon": "$(cloud-upload)"
},
{
"command": "gitlens.views.pull",
"title": "Pull",
Expand Down Expand Up @@ -5456,6 +5462,10 @@
"command": "gitlens.views.publishBranch",
"when": "false"
},
{
"command": "gitlens.views.publishRepository",
"when": "false"
},
{
"command": "gitlens.views.pull",
"when": "false"
Expand Down Expand Up @@ -7906,10 +7916,15 @@
"group": "8_gitlens_actions_@2"
},
{
"command": "gitlens.views.addRemote",
"command": "gitlens.views.publishRepository",
"when": "!gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:status(\\-branch)?:upstream:none/",
"group": "inline@1"
},
{
"command": "gitlens.views.addRemote",
"when": "!gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:status(\\-branch)?:upstream:none/",
"group": "inline@2"
},
{
"command": "gitlens.views.publishBranch",
"when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:status(\\-branch)?:upstream:none/",
Expand Down
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export enum BuiltInCommands {
}

export enum BuiltInGitCommands {
Publish = 'git.publish',
Pull = 'git.pull',
PullRebase = 'git.pullRebase',
Push = 'git.push',
Expand Down
9 changes: 9 additions & 0 deletions src/views/viewCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export class ViewCommands {

commands.registerCommand('gitlens.views.fetch', this.fetch, this);
commands.registerCommand('gitlens.views.publishBranch', this.publishBranch, this);
commands.registerCommand('gitlens.views.publishRepository', this.publishRepository, this);
commands.registerCommand('gitlens.views.pull', this.pull, this);
commands.registerCommand('gitlens.views.push', this.push, this);
commands.registerCommand('gitlens.views.pushWithForce', n => this.push(n, true), this);
Expand Down Expand Up @@ -452,6 +453,14 @@ export class ViewCommands {
return Promise.resolve();
}

@debug()
private publishRepository(node: BranchNode | BranchTrackingStatusNode) {
if (node instanceof BranchNode || node instanceof BranchTrackingStatusNode) {
return commands.executeCommand(BuiltInGitCommands.Publish, Uri.file(node.repoPath));
}
return Promise.resolve();
}

@debug()
private pull(node: RepositoryNode | BranchNode | BranchTrackingStatusNode) {
if (node instanceof RepositoryNode) return GitActions.pull(node.repo);
Expand Down

0 comments on commit 1e0bcfa

Please sign in to comment.