Преглед на файлове

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;
}

Зареждане…
Отказ
Запис