diff --git a/src/git/models/status.ts b/src/git/models/status.ts index c5ca748..57af51a 100644 --- a/src/git/models/status.ts +++ b/src/git/models/status.ts @@ -199,9 +199,9 @@ export class GitStatus { state: { ahead: number; behind: number }, options: { empty?: string; expand?: boolean; prefix?: string; separator?: string; suffix?: string } = {}, ): string { + const { expand = false, prefix = '', separator = ' ', suffix = '' } = options; if (upstream == null || (state.behind === 0 && state.ahead === 0)) return options.empty ?? ''; - const { expand, prefix = '', separator = ' ', suffix = '' } = options; if (expand) { let status = ''; if (state.behind) { @@ -209,6 +209,9 @@ export class GitStatus { } if (state.ahead) { status += `${status.length === 0 ? '' : separator}${Strings.pluralize('commit', state.ahead)} ahead`; + if (suffix.endsWith(upstream)) { + status += ' of'; + } } return `${prefix}${status}${suffix}`; } diff --git a/src/views/nodes/branchNode.ts b/src/views/nodes/branchNode.ts index 2ea8a47..8adf82b 100644 --- a/src/views/nodes/branchNode.ts +++ b/src/views/nodes/branchNode.ts @@ -213,10 +213,11 @@ export class BranchNode GlyphChars.Space } ${this.branch.tracking}`; - tooltip += ` is tracking ${this.branch.tracking}\n${this.branch.getTrackingStatus({ - empty: 'up-to-date', + tooltip += ` is ${this.branch.getTrackingStatus({ + empty: `up to date with ${this.branch.tracking}`, expand: true, - separator: '\n', + separator: ', ', + suffix: ` ${this.branch.tracking}`, })}`; if (this.branch.state.ahead || this.branch.state.behind) { diff --git a/src/views/nodes/branchTrackingStatusNode.ts b/src/views/nodes/branchTrackingStatusNode.ts index 5a3988b..fa53545 100644 --- a/src/views/nodes/branchTrackingStatusNode.ts +++ b/src/views/nodes/branchTrackingStatusNode.ts @@ -129,10 +129,10 @@ export class BranchTrackingStatusNode extends ViewNode implement switch (this.upstreamType) { case 'ahead': label = `${Strings.pluralize('commit', this.status.state.ahead)} ahead`; + tooltip = `${this.branch.name} is ${label} of ${this.status.upstream}`; if (!this.isReposView) { label = `${this.root ? `${this.branch.name} is ` : ''}${label} of ${this.status.upstream}`; } - tooltip = `${label} of ${this.status.upstream}`; collapsibleState = !this.isReposView ? TreeItemCollapsibleState.Expanded @@ -146,10 +146,10 @@ export class BranchTrackingStatusNode extends ViewNode implement case 'behind': label = `${Strings.pluralize('commit', this.status.state.behind)} behind`; + tooltip = `${this.branch.name} is ${label} ${this.status.upstream}`; if (!this.isReposView) { label = `${this.root ? `${this.branch.name} is ` : ''}${label} ${this.status.upstream}`; } - tooltip = `${label} ${this.status.upstream}`; collapsibleState = TreeItemCollapsibleState.Collapsed; contextValue = this.root @@ -161,10 +161,10 @@ export class BranchTrackingStatusNode extends ViewNode implement case 'same': label = `${this.branch.name} is up to date`; + tooltip = `${label} with ${this.status.upstream}`; if (!this.isReposView) { label += ` with ${this.status.upstream}`; } - tooltip = `${label} with ${this.status.upstream}`; collapsibleState = TreeItemCollapsibleState.None; contextValue = this.root ? ContextValues.StatusSameAsUpstream : undefined; @@ -185,9 +185,10 @@ export class BranchTrackingStatusNode extends ViewNode implement const item = new TreeItem(label, collapsibleState); item.id = this.id; item.contextValue = contextValue; - item.description = lastFetched - ? `Last fetched ${Dates.getFormatter(new Date(lastFetched)).fromNow()}` - : undefined; + if (lastFetched) { + item.description = `Last fetched ${Dates.getFormatter(new Date(lastFetched)).fromNow()}`; + tooltip += `\n${item.description}`; + } item.iconPath = new ThemeIcon(icon); item.tooltip = tooltip;