Преглед изворни кода

Fixes title issue with newly added files

main
Eric Amodio пре 6 година
родитељ
комит
c4483b1b91
4 измењених фајлова са 14 додато и 9 уклоњено
  1. +1
    -1
      src/commands/diffWith.ts
  2. +6
    -4
      src/git/git.ts
  3. +1
    -1
      src/git/models/commit.ts
  4. +6
    -3
      src/gitService.ts

+ 1
- 1
src/commands/diffWith.ts Прегледај датотеку

@ -136,7 +136,7 @@ export class DiffWithCommand extends ActiveEditorCommand {
args.lhs.title = `${path.basename(args.lhs.uri.fsPath)}${suffix !== '' ? ` (${lhsPrefix}${suffix})` : ''}`;
}
if (args.rhs.title === undefined && args.rhs.sha !== GitService.deletedSha) {
const suffix = GitService.shortenSha(args.rhs.sha) || '';
const suffix = GitService.shortenSha(args.rhs.sha, { uncommitted: 'working tree' }) || '';
args.rhs.title = `${path.basename(args.rhs.uri.fsPath)}${suffix !== '' ? ` (${rhsPrefix}${suffix})` : rhsPrefix}`;
}

+ 6
- 4
src/git/git.ts Прегледај датотеку

@ -183,7 +183,7 @@ export class Git {
ref = '';
}
const suffix = Strings.truncate(Strings.sanitizeForFileSystem(Git.isSha(ref) ? Git.shortenSha(ref) : ref), 50, '');
const suffix = Strings.truncate(Strings.sanitizeForFileSystem(Git.isSha(ref) ? Git.shortenSha(ref)! : ref), 50, '');
const ext = path.extname(fileName);
const tmp = await import('tmp');
@ -224,9 +224,11 @@ export class Git {
return sha === undefined ? false : Git.uncommittedRegex.test(sha);
}
static shortenSha(sha: string) {
if (Git.isStagedUncommitted(sha)) return 'index';
if (Git.isUncommitted(sha)) return '';
static shortenSha(sha: string, strings: { deleted?: string, stagedUncommitted?: string, uncommitted?: string } = {}) {
strings = { uncommitted: '', stagedUncommitted: 'index', ...strings };
if (Git.isStagedUncommitted(sha)) return strings.stagedUncommitted;
if (Git.isUncommitted(sha)) return strings.uncommitted;
const index = sha.indexOf('^');
if (index > 6) {

+ 1
- 1
src/git/models/commit.ts Прегледај датотеку

@ -122,7 +122,7 @@ export abstract class GitCommit {
protected _resolvedPreviousFileSha: string | undefined;
get previousFileShortSha(): string {
return Git.shortenSha(this.previousFileSha);
return Git.shortenSha(this.previousFileSha)!;
}
get previousSha(): string | undefined {

+ 6
- 3
src/gitService.ts Прегледај датотеку

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

Loading…
Откажи
Сачувај