From aa5b346b69c6669ee4e7335419fd1a4e4d50b3e3 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Sun, 14 Jul 2019 12:44:54 -0400 Subject: [PATCH] Fixes issues with branch status node commands --- package.json | 2 +- src/views/nodes/branchNode.ts | 4 ++-- src/views/nodes/branchTrackingStatusNode.ts | 7 ++++--- src/views/nodes/commitNode.ts | 2 +- src/views/nodes/compareBranchNode.ts | 2 +- src/views/nodes/repositoryNode.ts | 4 ++-- src/views/nodes/viewNode.ts | 4 ++-- 7 files changed, 13 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index c0675a0..c93c358 100644 --- a/package.json +++ b/package.json @@ -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" }, { diff --git a/src/views/nodes/branchNode.ts b/src/views/nodes/branchNode.ts index d6bcdae..a2351b8 100644 --- a/src/views/nodes/branchNode.ts +++ b/src/views/nodes/branchNode.ts @@ -69,11 +69,11 @@ export class BranchNode extends ViewRefNode 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')); } } diff --git a/src/views/nodes/branchTrackingStatusNode.ts b/src/views/nodes/branchTrackingStatusNode.ts index 9e78a33..095c29b 100644 --- a/src/views/nodes/branchTrackingStatusNode.ts +++ b/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'; @@ -24,6 +24,7 @@ export class BranchTrackingStatusNode extends ViewNode 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 @@ -62,12 +63,12 @@ export class BranchTrackingStatusNode extends ViewNode 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 ) diff --git a/src/views/nodes/commitNode.ts b/src/views/nodes/commitNode.ts index 44efafa..e09f4b9 100644 --- a/src/views/nodes/commitNode.ts +++ b/src/views/nodes/commitNode.ts @@ -65,7 +65,7 @@ export class CommitNode extends ViewRefNode { 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, { diff --git a/src/views/nodes/compareBranchNode.ts b/src/views/nodes/compareBranchNode.ts index e58cf49..f692294 100644 --- a/src/views/nodes/compareBranchNode.ts +++ b/src/views/nodes/compareBranchNode.ts @@ -33,7 +33,7 @@ export class CompareBranchNode extends ViewNode { } 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[] { diff --git a/src/views/nodes/repositoryNode.ts b/src/views/nodes/repositoryNode.ts index acbf779..09fd262 100644 --- a/src/views/nodes/repositoryNode.ts +++ b/src/views/nodes/repositoryNode.ts @@ -63,11 +63,11 @@ export class RepositoryNode extends SubscribeableViewNode { 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)) { diff --git a/src/views/nodes/viewNode.ts b/src/views/nodes/viewNode.ts index ee8ce3e..cf20389 100644 --- a/src/views/nodes/viewNode.ts +++ b/src/views/nodes/viewNode.ts @@ -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',