瀏覽代碼

Fixes compact mode for stashes in quick picks

main
Eric Amodio 5 年之前
父節點
當前提交
1c7901efeb
共有 2 個文件被更改,包括 31 次插入5 次删除
  1. +11
    -0
      src/git/models/stashCommit.ts
  2. +20
    -5
      src/quickpicks/gitQuickPicks.ts

+ 11
- 0
src/git/models/stashCommit.ts 查看文件

@ -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 查看文件

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

Loading…
取消
儲存