diff --git a/src/git/models/status.ts b/src/git/models/status.ts index 0119af4..0384e2e 100644 --- a/src/git/models/status.ts +++ b/src/git/models/status.ts @@ -5,7 +5,7 @@ import { GlyphChars } from '../../constants'; import { Container } from '../../container'; import { GitFile, GitFileStatus } from './file'; import { GitUri } from '../gitUri'; -import { GitCommitType, GitLogCommit, GitRevision } from './models'; +import { GitCommitType, GitLogCommit, GitRemote, GitRevision } from './models'; import { memoize, Strings } from '../../system'; export interface ComputedWorkingTreeGitStatus { @@ -184,6 +184,17 @@ export class GitStatus { return `${prefix}${status}${suffix}`; } + @memoize() + async getRemote(): Promise { + if (this.upstream == null) return undefined; + + const remotes = await Container.git.getRemotes(this.repoPath); + if (remotes.length === 0) return undefined; + + const remoteName = GitBranch.getRemote(this.upstream); + return remotes.find(r => r.name === remoteName); + } + getUpstreamStatus(options: { empty?: string; expand?: boolean; diff --git a/src/views/nodes/repositoryNode.ts b/src/views/nodes/repositoryNode.ts index 1268994..4a799c8 100644 --- a/src/views/nodes/repositoryNode.ts +++ b/src/views/nodes/repositoryNode.ts @@ -4,6 +4,7 @@ import { GlyphChars } from '../../constants'; import { Container } from '../../container'; import { GitBranch, + GitRemote, GitRevision, GitStatus, Repository, @@ -137,8 +138,8 @@ export class RepositoryNode extends SubscribeableViewNode { } const status = await this._status; - if (status !== undefined) { - tooltip += `\n\nCurrent branch is ${status.branch}`; + if (status != null) { + tooltip += `\n\nBranch ${status.branch}`; if (status.files.length !== 0 && this.includeWorkingTree) { workingStatus = status.getFormattedDiffStatus({ @@ -153,12 +154,22 @@ export class RepositoryNode extends SubscribeableViewNode { description = `${status.branch}${upstreamStatus}${workingStatus}`; + let providerName; + if (status.upstream != null) { + const providers = GitRemote.getHighlanderProviders(await Container.git.getRemotes(status.repoPath)); + providerName = providers?.length ? providers[0].name : undefined; + } else { + const remote = await status.getRemote(); + providerName = remote?.provider?.name; + } + iconSuffix = workingStatus ? '-blue' : ''; - if (status.upstream !== undefined) { - tooltip += ` and is tracking ${status.upstream}\n${status.getUpstreamStatus({ - empty: 'No commits ahead or behind', + if (status.upstream != null) { + tooltip += ` is ${status.getUpstreamStatus({ + empty: `up to date with ${status.upstream}${providerName ? ` on ${providerName}` : ''}`, expand: true, - separator: '\n', + separator: ',', + suffix: ` ${status.upstream}${providerName ? ` on ${providerName}` : ''}`, })}`; if (status.state.behind) {