Browse Source

Adds pull to behind upstream & push to ahead upstream nodes

main
Eric Amodio 6 years ago
parent
commit
37bf8835f4
4 changed files with 34 additions and 6 deletions
  1. +21
    -1
      package.json
  2. +3
    -2
      src/views/nodes/statusUpstreamNode.ts
  3. +2
    -1
      src/views/nodes/viewNode.ts
  4. +8
    -2
      src/views/viewCommands.ts

+ 21
- 1
package.json View File

@ -3495,11 +3495,31 @@
{ {
"command": "gitlens.views.pull", "command": "gitlens.views.pull",
"when": "viewItem == gitlens:repository && gitlens:hasRemotes", "when": "viewItem == gitlens:repository && gitlens:hasRemotes",
"group": "1_gitlens@2"
"group": "1_gitlens@1"
}, },
{ {
"command": "gitlens.views.push", "command": "gitlens.views.push",
"when": "viewItem == gitlens:repository && gitlens:hasRemotes", "when": "viewItem == gitlens:repository && gitlens:hasRemotes",
"group": "1_gitlens@1"
},
{
"command": "gitlens.views.pull",
"when": "viewItem == gitlens:status:upstream:behind && gitlens:hasRemotes",
"group": "inline@1"
},
{
"command": "gitlens.views.push",
"when": "viewItem == gitlens:status:upstream:ahead && gitlens:hasRemotes",
"group": "inline@1"
},
{
"command": "gitlens.views.pull",
"when": "viewItem == gitlens:status:upstream:behind && gitlens:hasRemotes",
"group": "1_gitlens@2"
},
{
"command": "gitlens.views.push",
"when": "viewItem == gitlens:status:upstream:ahead && gitlens:hasRemotes",
"group": "1_gitlens@3" "group": "1_gitlens@3"
}, },
{ {

+ 3
- 2
src/views/nodes/statusUpstreamNode.ts View File

@ -7,6 +7,7 @@ import { RepositoriesView } from '../repositoriesView';
import { CommitNode } from './commitNode'; import { CommitNode } from './commitNode';
import { ShowMoreNode } from './common'; import { ShowMoreNode } from './common';
import { insertDateMarkers } from './helpers'; import { insertDateMarkers } from './helpers';
import { RepositoryNode } from './repositoryNode';
import { PageableViewNode, ResourceType, ViewNode } from './viewNode'; import { PageableViewNode, ResourceType, ViewNode } from './viewNode';
export class StatusUpstreamNode extends ViewNode implements PageableViewNode { export class StatusUpstreamNode extends ViewNode implements PageableViewNode {
@ -16,7 +17,7 @@ export class StatusUpstreamNode extends ViewNode implements PageableViewNode {
constructor( constructor(
public readonly status: GitStatus, public readonly status: GitStatus,
public readonly direction: 'ahead' | 'behind', public readonly direction: 'ahead' | 'behind',
parent: ViewNode,
parent: RepositoryNode,
public readonly view: RepositoriesView public readonly view: RepositoriesView
) { ) {
super(GitUri.fromRepoPath(status.repoPath), parent); super(GitUri.fromRepoPath(status.repoPath), parent);
@ -76,7 +77,7 @@ export class StatusUpstreamNode extends ViewNode implements PageableViewNode {
const item = new TreeItem(label, TreeItemCollapsibleState.Collapsed); const item = new TreeItem(label, TreeItemCollapsibleState.Collapsed);
item.id = this.id; item.id = this.id;
item.contextValue = ResourceType.StatusUpstream;
item.contextValue = ahead ? ResourceType.StatusAheadOfUpstream : ResourceType.StatusBehindUpstream;
item.tooltip = `${label}${ahead ? ' of ' : ''}${this.status.upstream}`; item.tooltip = `${label}${ahead ? ' of ' : ''}${this.status.upstream}`;
const iconSuffix = ahead ? 'upload' : 'download'; const iconSuffix = ahead ? 'upload' : 'download';

+ 2
- 1
src/views/nodes/viewNode.ts View File

@ -40,7 +40,8 @@ export enum ResourceType {
Stashes = 'gitlens:stashes', Stashes = 'gitlens:stashes',
StatusFileCommits = 'gitlens:status:file:commits', StatusFileCommits = 'gitlens:status:file:commits',
StatusFiles = 'gitlens:status:files', StatusFiles = 'gitlens:status:files',
StatusUpstream = 'gitlens:status:upstream',
StatusAheadOfUpstream = 'gitlens:status:upstream:ahead',
StatusBehindUpstream = 'gitlens:status:upstream:behind',
Tag = 'gitlens:tag', Tag = 'gitlens:tag',
Tags = 'gitlens:tags' Tags = 'gitlens:tags'
} }

+ 8
- 2
src/views/viewCommands.ts View File

@ -113,13 +113,19 @@ export class ViewCommands implements Disposable {
return node.fetch(); return node.fetch();
} }
private pull(node: RepositoryNode) {
private pull(node: RepositoryNode | StatusUpstreamNode) {
if (node instanceof StatusUpstreamNode) {
node = node.getParent() as RepositoryNode;
}
if (!(node instanceof RepositoryNode)) return; if (!(node instanceof RepositoryNode)) return;
return node.pull(); return node.pull();
} }
private push(node: RepositoryNode) {
private push(node: RepositoryNode | StatusUpstreamNode) {
if (node instanceof StatusUpstreamNode) {
node = node.getParent() as RepositoryNode;
}
if (!(node instanceof RepositoryNode)) return; if (!(node instanceof RepositoryNode)) return;
return node.push(); return node.push();

Loading…
Cancel
Save