Browse Source

Aligns repo tooltip with commits view

main
Eric Amodio 4 years ago
parent
commit
fd9f8270bf
2 changed files with 29 additions and 7 deletions
  1. +12
    -1
      src/git/models/status.ts
  2. +17
    -6
      src/views/nodes/repositoryNode.ts

+ 12
- 1
src/git/models/status.ts View File

@ -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<GitRemote | undefined> {
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;

+ 17
- 6
src/views/nodes/repositoryNode.ts View File

@ -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) {

Loading…
Cancel
Save