Skip to content

Commit

Permalink
Adds add remote cmd when there are no remotes
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Jan 6, 2021
1 parent 6835d08 commit 4c7051c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Added

- Adds a new _Quick Open File History_ command to all places where _Open File History_ already exists — closes [#1156](https://github.com/eamodio/vscode-gitlens/issues/1156)
- Adds _Add Remote_ command to the branch status in the _Branches_, _Commits_, and _Repositories_ views when there are no Git remotes configured

## [11.1.3] - 2021-01-05

Expand Down
23 changes: 14 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6987,22 +6987,22 @@
},
{
"command": "gitlens.views.publishBranch",
"when": "!gitlens:readonly && viewItem =~ /gitlens:branch\\b(?!.*?\\b\\+tracking\\b)/",
"when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:branch\\b(?!.*?\\b\\+tracking\\b)/",
"group": "inline@8"
},
{
"command": "gitlens.views.push",
"when": "!gitlens:readonly && viewItem =~ /gitlens:branch\\b(?=.*?\\b\\+ahead\\b)(?!.*?\\b\\+behind\\b)/",
"when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:branch\\b(?=.*?\\b\\+ahead\\b)(?!.*?\\b\\+behind\\b)/",
"group": "inline@8"
},
{
"command": "gitlens.views.pull",
"when": "!gitlens:readonly && viewItem =~ /gitlens:branch\\b(?=.*?\\b\\+behind\\b)/",
"when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:branch\\b(?=.*?\\b\\+behind\\b)/",
"group": "inline@8"
},
{
"command": "gitlens.views.fetch",
"when": "!gitlens:readonly && viewItem =~ /gitlens:branch\\b(?!.*?\\b\\+ahead\\b)(?!.*?\\b\\+behind\\b)/",
"when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:branch\\b(?=.*?\\b\\+tracking\\b)(?!.*?\\b\\+ahead\\b)(?!.*?\\b\\+behind\\b)/",
"group": "inline@8"
},
{
Expand All @@ -7012,7 +7012,7 @@
},
{
"command": "gitlens.views.pushToCommit",
"when": "!gitlens:readonly && viewItem =~ /gitlens:commit\\b(?=.*?\\b\\+current\\b)(?=.*?\\b\\+unpublished\\b)/",
"when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:commit\\b(?=.*?\\b\\+current\\b)(?=.*?\\b\\+unpublished\\b)/",
"group": "inline@96"
},
{
Expand Down Expand Up @@ -7650,25 +7650,30 @@
"when": "viewItem =~ /gitlens:repo-folder\\b/",
"group": "8_gitlens_actions_@2"
},
{
"command": "gitlens.views.addRemote",
"when": "!gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:status(\\-branch)?:upstream:none/",
"group": "inline@1"
},
{
"command": "gitlens.views.publishBranch",
"when": "gitlens:hasRemotes && !gitlens:readonly && viewItem == gitlens:status:upstream:none",
"when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:status(\\-branch)?:upstream:none/",
"group": "inline@1"
},
{
"command": "gitlens.views.push",
"when": "gitlens:hasRemotes && !gitlens:readonly && viewItem == gitlens:status:upstream:ahead",
"when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:status(\\-branch)?:upstream:ahead/",
"group": "inline@1",
"alt": "gitlens.views.pushWithForce"
},
{
"command": "gitlens.views.pull",
"when": "gitlens:hasRemotes && !gitlens:readonly && viewItem == gitlens:status:upstream:behind",
"when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:status(\\-branch)?:upstream:behind/",
"group": "inline@1"
},
{
"command": "gitlens.views.fetch",
"when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:status:upstream:(?!none)/",
"when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:status(\\-branch)?:upstream:(?!none)/",
"group": "inline@2"
},
{
Expand Down
16 changes: 10 additions & 6 deletions src/views/nodes/branchTrackingStatusNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,16 @@ export class BranchTrackingStatusNode extends ViewNode<ViewsWithCommits> impleme
}${remote?.provider?.name ? ` on ${remote.provider.name}` : ''}`;

collapsibleState = TreeItemCollapsibleState.None;
contextValue = this.root ? ContextValues.StatusSameAsUpstream : undefined;
contextValue = this.root
? ContextValues.StatusSameAsUpstream
: ContextValues.BranchStatusSameAsUpstream;
icon = new ThemeIcon('cloud');

break;
}
case 'none': {
const providers = GitRemote.getHighlanderProviders(
await Container.git.getRemotes(this.branch.repoPath),
);
const remotes = await Container.git.getRemotes(this.branch.repoPath);
const providers = GitRemote.getHighlanderProviders(remotes);
const providerName = providers?.length ? providers[0].name : undefined;

label = `Publish ${this.branch.name} to ${providerName ?? 'a remote'}`;
Expand All @@ -233,8 +234,11 @@ export class BranchTrackingStatusNode extends ViewNode<ViewsWithCommits> impleme
}`;

collapsibleState = TreeItemCollapsibleState.None;
contextValue = this.root ? ContextValues.StatusNoUpstream : undefined;
icon = new ThemeIcon('cloud-upload', new ThemeColor('gitlens.viewChangesToPushIconColor'));
contextValue = this.root ? ContextValues.StatusNoUpstream : ContextValues.BranchStatusNoUpstream;
icon = new ThemeIcon(
'cloud-upload',
remotes.length ? new ThemeColor('gitlens.viewChangesToPushIconColor') : undefined,
);

break;
}
Expand Down
2 changes: 2 additions & 0 deletions src/views/nodes/viewNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export enum ContextValues {
Branches = 'gitlens:branches',
BranchStatusAheadOfUpstream = 'gitlens:status-branch:upstream:ahead',
BranchStatusBehindUpstream = 'gitlens:status-branch:upstream:behind',
BranchStatusNoUpstream = 'gitlens:status-branch:upstream:none',
BranchStatusSameAsUpstream = 'gitlens:status-branch:upstream:same',
BranchStatusFiles = 'gitlens:status-branch:files',
Commit = 'gitlens:commit',
Commits = 'gitlens:commits',
Expand Down

0 comments on commit 4c7051c

Please sign in to comment.