Skip to content

Commit

Permalink
Fixes issues with branch status node commands
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Jul 14, 2019
1 parent 1ef212c commit aa5b346
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -4965,7 +4965,7 @@
},
{
"command": "gitlens.views.expandNode",
"when": "viewItem =~ /gitlens:(compare|folder|results|search|status:files)\\b/",
"when": "viewItem =~ /gitlens:(compare|folder|results|search|status)\\b/",
"group": "8_gitlens@1"
},
{
Expand Down
4 changes: 2 additions & 2 deletions src/views/nodes/branchNode.ts
Expand Up @@ -69,11 +69,11 @@ export class BranchNode extends ViewRefNode<RepositoriesView> implements Pageabl
};

if (this.branch.state.behind) {
children.push(new BranchTrackingStatusNode(this.view, this, status, 'behind'));
children.push(new BranchTrackingStatusNode(this.view, this, this.branch, status, 'behind'));
}

if (this.branch.state.ahead) {
children.push(new BranchTrackingStatusNode(this.view, this, status, 'ahead'));
children.push(new BranchTrackingStatusNode(this.view, this, this.branch, status, 'ahead'));
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/views/nodes/branchTrackingStatusNode.ts
@@ -1,7 +1,7 @@
'use strict';
import { TreeItem, TreeItemCollapsibleState } from 'vscode';
import { Container } from '../../container';
import { GitTrackingState, GitUri } from '../../git/gitService';
import { GitBranch, GitTrackingState, GitUri } from '../../git/gitService';
import { Iterables, Strings } from '../../system';
import { ViewWithFiles } from '../viewBase';
import { CommitNode } from './commitNode';
Expand All @@ -24,6 +24,7 @@ export class BranchTrackingStatusNode extends ViewNode<ViewWithFiles> implements
constructor(
view: ViewWithFiles,
parent: ViewNode,
public readonly branch: GitBranch,
public readonly status: BranchTrackingStatus,
public readonly direction: 'ahead' | 'behind',
// Specifies that the node is shown as a root under the repository node
Expand Down Expand Up @@ -62,12 +63,12 @@ export class BranchTrackingStatusNode extends ViewNode<ViewWithFiles> implements
}
}

children = [...insertDateMarkers(Iterables.map(commits, c => new CommitNode(this.view, this, c)), this, 1)];
children = [...insertDateMarkers(Iterables.map(commits, c => new CommitNode(this.view, this, c, this.branch)), this, 1)];
}
else {
children = [
...insertDateMarkers(
Iterables.map(log.commits.values(), c => new CommitNode(this.view, this, c)),
Iterables.map(log.commits.values(), c => new CommitNode(this.view, this, c, this.branch)),
this,
1
)
Expand Down
2 changes: 1 addition & 1 deletion src/views/nodes/commitNode.ts
Expand Up @@ -65,7 +65,7 @@ export class CommitNode extends ViewRefNode<ViewWithFiles> {

const item = new TreeItem(label, TreeItemCollapsibleState.Collapsed);
item.contextValue = ResourceType.Commit;
if (this.branch === undefined || this.branch.current) {
if (this.branch !== undefined && this.branch.current) {
item.contextValue += '+current';
}
item.description = CommitFormatter.fromTemplate(this.view.config.commitDescriptionFormat, this.commit, {
Expand Down
2 changes: 1 addition & 1 deletion src/views/nodes/compareBranchNode.ts
Expand Up @@ -33,7 +33,7 @@ export class CompareBranchNode extends ViewNode<RepositoriesView> {
}

get id(): string {
return `gitlens:repository(${this.branch.repoPath}):branch(${this.branch.name}):compareWith`;
return `gitlens:repository(${this.branch.repoPath}):compare:branch(${this.branch.name}):compareWith`;
}

getChildren(): ViewNode[] {
Expand Down
4 changes: 2 additions & 2 deletions src/views/nodes/repositoryNode.ts
Expand Up @@ -63,11 +63,11 @@ export class RepositoryNode extends SubscribeableViewNode<RepositoriesView> {
children.push(new BranchNode(this.uri, this.view, this, branch, true));

if (status.state.behind) {
children.push(new BranchTrackingStatusNode(this.view, this, status, 'behind', true));
children.push(new BranchTrackingStatusNode(this.view, this, branch, status, 'behind', true));
}

if (status.state.ahead) {
children.push(new BranchTrackingStatusNode(this.view, this, status, 'ahead', true));
children.push(new BranchTrackingStatusNode(this.view, this, branch, status, 'ahead', true));
}

if (status.state.ahead || (status.files.length !== 0 && this.includeWorkingTree)) {
Expand Down
4 changes: 2 additions & 2 deletions src/views/nodes/viewNode.ts
Expand Up @@ -10,8 +10,8 @@ export enum ResourceType {
ActiveLineHistory = 'gitlens:history:active:line',
Branch = 'gitlens:branch',
Branches = 'gitlens:branches',
BranchStatusAheadOfUpstream = 'gitlens:branch-status:upstream:ahead',
BranchStatusBehindUpstream = 'gitlens:branch-status:upstream:behind',
BranchStatusAheadOfUpstream = 'gitlens:status-branch:upstream:ahead',
BranchStatusBehindUpstream = 'gitlens:status-branch:upstream:behind',
Commit = 'gitlens:commit',
Commits = 'gitlens:commits',
Compare = 'gitlens:compare',
Expand Down

0 comments on commit aa5b346

Please sign in to comment.