Browse Source

Adds working tree string to shortenSha

main
Eric Amodio 6 years ago
parent
commit
e1f62a01cf
3 changed files with 7 additions and 5 deletions
  1. +3
    -2
      src/git/git.ts
  2. +3
    -2
      src/gitService.ts
  3. +1
    -1
      src/views/comparisonResultsNode.ts

+ 3
- 2
src/git/git.ts View File

@ -225,9 +225,10 @@ export class Git {
return sha === undefined ? false : Git.uncommittedRegex.test(sha);
}
static shortenSha(sha: string, strings: { deleted?: string, stagedUncommitted?: string, uncommitted?: string } = {}) {
strings = { uncommitted: '', stagedUncommitted: 'index', ...strings };
static shortenSha(sha: string, strings: { stagedUncommitted?: string, uncommitted?: string, working?: string } = {}) {
strings = { stagedUncommitted: 'index', uncommitted: '', working: '', ...strings };
if (sha === '') return strings.working;
if (Git.isStagedUncommitted(sha)) return strings.stagedUncommitted;
if (Git.isUncommitted(sha)) return strings.uncommitted;

+ 3
- 2
src/gitService.ts View File

@ -1454,11 +1454,12 @@ export class GitService extends Disposable {
return Git.isUncommitted(sha);
}
static shortenSha(sha: string | undefined, strings: { deleted?: string, stagedUncommitted?: string, uncommitted?: string } = {}) {
static shortenSha(sha: string | undefined, strings: { deleted?: string, stagedUncommitted?: string, uncommitted?: string, working?: string } = {}) {
if (sha === undefined) return undefined;
strings = { deleted: '(deleted)', ...strings };
strings = { deleted: '(deleted)', working: '', ...strings };
if (sha === '') return strings.working;
if (sha === GitService.deletedSha) return strings.deleted;
return Git.isSha(sha) || Git.isStagedUncommitted(sha)

+ 1
- 1
src/views/comparisonResultsNode.ts View File

@ -54,7 +54,7 @@ export class ComparisonResultsNode extends ExplorerNode {
repository = ` ${Strings.pad(GlyphChars.Dash, 1, 1)} ${(repo && repo.formattedName) || this.uri.repoPath}`;
}
const item = new TreeItem(`Comparing ${GitService.shortenSha(this.ref1)} to ${this.ref2 !== '' ? GitService.shortenSha(this.ref2) : 'Working Tree'}${repository}`, TreeItemCollapsibleState.Expanded);
const item = new TreeItem(`Comparing ${GitService.shortenSha(this.ref1, { working: 'Working Tree' })} to ${GitService.shortenSha(this.ref2, { working: 'Working Tree' })}${repository}`, TreeItemCollapsibleState.Expanded);
item.contextValue = ResourceType.ComparisonResults;
return item;
}

Loading…
Cancel
Save