Przeglądaj źródła

Fixes compact mode for stashes in quick picks

main
Eric Amodio 5 lat temu
rodzic
commit
1c7901efeb
2 zmienionych plików z 31 dodań i 5 usunięć
  1. +11
    -0
      src/git/models/stashCommit.ts
  2. +20
    -5
      src/quickpicks/gitQuickPicks.ts

+ 11
- 0
src/git/models/stashCommit.ts Wyświetl plik

@ -2,6 +2,9 @@
import { GitCommitType } from './commit';
import { GitFile } from './file';
import { GitLogCommit } from './logCommit';
import { memoize } from '../../system';
const stashNumberRegex = /stash@{(\d+)}/;
export class GitStashCommit extends GitLogCommit {
static is(commit: any): commit is GitStashCommit {
@ -27,6 +30,14 @@ export class GitStashCommit extends GitLogCommit {
super(type, repoPath, sha, 'You', undefined, authorDate, committedDate, message, fileName, files);
}
@memoize()
get number() {
const match = stashNumberRegex.exec(this.stashName);
if (match == null) return undefined;
return match[1];
}
get shortSha() {
return this.stashName;
}

+ 20
- 5
src/quickpicks/gitQuickPicks.ts Wyświetl plik

@ -159,16 +159,31 @@ export namespace CommitQuickPickItem {
options: { compact?: boolean; icon?: boolean; match?: string } = {}
) {
if (GitStashCommit.is(commit)) {
const number = commit.number === undefined ? '' : `${commit.number}: `;
if (options.compact) {
const item: CommitQuickPickItem<T> = {
label: `${number}${commit.getShortMessage()}`,
description: `${commit.formattedDate}${Strings.pad(
GlyphChars.Dot,
2,
2
)}${commit.getFormattedDiffStatus({ compact: true })}`,
picked: picked,
item: commit
};
return item;
}
const item: CommitQuickPickItem<T> = {
label: commit.getShortMessage(),
label: `${number}${commit.getShortMessage()}`,
description: '',
detail: `${GlyphChars.Space.repeat(2)}${commit.stashName || commit.shortSha}${Strings.pad(
detail: `${GlyphChars.Space.repeat(2)}${commit.formattedDate}${Strings.pad(
GlyphChars.Dot,
2,
2
)}${commit.formattedDate}${Strings.pad(GlyphChars.Dot, 2, 2)}${commit.getFormattedDiffStatus({
compact: true
})}`,
)}${commit.getFormattedDiffStatus({ compact: true })}`,
picked: picked,
item: commit
};

Ładowanie…
Anuluj
Zapisz