From aa2c41be4ff96fc88696721d41866c18bbd3c707 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Wed, 26 Aug 2020 03:07:01 -0400 Subject: [PATCH] Adds upstream to Commits view tracking node --- src/views/nodes/branchTrackingStatusNode.ts | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/views/nodes/branchTrackingStatusNode.ts b/src/views/nodes/branchTrackingStatusNode.ts index 55cf2e4..923931c 100644 --- a/src/views/nodes/branchTrackingStatusNode.ts +++ b/src/views/nodes/branchTrackingStatusNode.ts @@ -9,7 +9,7 @@ import { GitBranch, GitLog, GitRevision, GitTrackingState } from '../../git/git' import { GitUri } from '../../git/gitUri'; import { insertDateMarkers } from './helpers'; import { RepositoriesView } from '../repositoriesView'; -import { debug, gate, Iterables, Strings } from '../../system'; +import { debug, gate, Iterables, memoize, Strings } from '../../system'; import { ViewsWithFiles } from '../viewBase'; import { ContextValues, PageableViewNode, ViewNode } from './viewNode'; @@ -97,12 +97,7 @@ export class BranchTrackingStatusNode extends ViewNode implement children.push(new ShowMoreNode(this.view, this, children[children.length - 1])); } - if ( - !(this.view instanceof RepositoriesView) && - this.status.upstream && - this.ahead && - this.status.state.ahead > 0 - ) { + if (!this.isReposView && this.status.upstream && this.ahead && this.status.state.ahead > 0) { children.push( new BranchTrackingStatusFilesNode( this.view, @@ -120,15 +115,16 @@ export class BranchTrackingStatusNode extends ViewNode implement getTreeItem(): TreeItem { const ahead = this.ahead; - const label = ahead + let label = ahead ? `${Strings.pluralize('commit', this.status.state.ahead)} ahead` : `${Strings.pluralize('commit', this.status.state.behind)} behind`; + if (!this.isReposView) { + label += `${ahead ? ' of ' : ' '}${this.status.upstream}`; + } const item = new TreeItem( label, - ahead && !(this.view instanceof RepositoriesView) - ? TreeItemCollapsibleState.Expanded - : TreeItemCollapsibleState.Collapsed, + ahead && !this.isReposView ? TreeItemCollapsibleState.Expanded : TreeItemCollapsibleState.Collapsed, ); item.id = this.id; if (this.root) { @@ -143,6 +139,11 @@ export class BranchTrackingStatusNode extends ViewNode implement return item; } + @memoize() + private get isReposView() { + return this.view instanceof RepositoriesView; + } + @gate() @debug() refresh(reset?: boolean) {