From e3c9fd53ca060c681bb1428349350fc9fb6d687f Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Wed, 29 Mar 2017 00:44:02 -0400 Subject: [PATCH] Changes quick pick item structure of the stash list --- src/quickPicks/branchHistory.ts | 2 +- src/quickPicks/common.ts | 14 ++++++++------ src/quickPicks/stashList.ts | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/quickPicks/branchHistory.ts b/src/quickPicks/branchHistory.ts index 44fa952..ff34c63 100644 --- a/src/quickPicks/branchHistory.ts +++ b/src/quickPicks/branchHistory.ts @@ -18,7 +18,7 @@ export class BranchHistoryQuickPick { } static async show(git: GitService, log: IGitLog, uri: GitUri, branch: string, progressCancellation: CancellationTokenSource, goBackCommand?: CommandQuickPickItem, nextPageCommand?: CommandQuickPickItem): Promise { - const items = Array.from(Iterables.map(log.commits.values(), c => new CommitQuickPickItem(c, ` \u2014 ${c.fileNames}`))) as (CommitQuickPickItem | CommandQuickPickItem)[]; + const items = Array.from(Iterables.map(log.commits.values(), c => new CommitQuickPickItem(c))) as (CommitQuickPickItem | CommandQuickPickItem)[]; const currentCommand = new CommandQuickPickItem({ label: `go back \u21A9`, diff --git a/src/quickPicks/common.ts b/src/quickPicks/common.ts index bfe0410..1d97b1c 100644 --- a/src/quickPicks/common.ts +++ b/src/quickPicks/common.ts @@ -2,7 +2,7 @@ import { CancellationTokenSource, commands, Disposable, QuickPickItem, QuickPickOptions, TextEditor, Uri, window, workspace } from 'vscode'; import { Commands, Keyboard, KeyboardScope, KeyMapping, openEditor } from '../commands'; import { IAdvancedConfig } from '../configuration'; -import { GitCommit } from '../gitService'; +import { GitCommit, GitLogCommit, GitStashCommit } from '../gitService'; // import { Logger } from '../logger'; import * as moment from 'moment'; @@ -116,14 +116,16 @@ export class CommitQuickPickItem implements QuickPickItem { description: string; detail: string; - constructor(public commit: GitCommit, descriptionSuffix: string = '') { - if (commit.author) { - this.label = `${commit.author}, ${moment(commit.date).fromNow()}`; + constructor(public commit: GitCommit) { + if (commit instanceof GitStashCommit) { + this.label = `${commit.stashName}, ${moment(commit.date).fromNow()}`; + this.description = `\u00a0\u00a0\u2014\u00a0\u00a0 ${commit.fileNames}`; //\u00a0\u00a0 $(git-commit) ${commit.shortSha} } else { - this.label = `${moment(commit.date).fromNow()}`; + this.label = `${commit.author}, ${moment(commit.date).fromNow()}`; + const suffix = commit.type === 'branch' ? ` \u2014 ${(commit as GitLogCommit).fileNames}` : ''; + this.description = `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.shortSha}${suffix}`; } - this.description = `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.shortSha}${descriptionSuffix}`; this.detail = commit.message; } } \ No newline at end of file diff --git a/src/quickPicks/stashList.ts b/src/quickPicks/stashList.ts index b2de4a8..dcf1f68 100644 --- a/src/quickPicks/stashList.ts +++ b/src/quickPicks/stashList.ts @@ -8,7 +8,7 @@ import { CommandQuickPickItem, CommitQuickPickItem, getQuickPickIgnoreFocusOut } export class StashListQuickPick { static async show(stash: IGitStash, placeHolder?: string, goBackCommand?: CommandQuickPickItem): Promise { - const items = ((stash && Array.from(Iterables.map(stash.commits.values(), c => new CommitQuickPickItem(c, ` \u2014 ${c.fileNames}`)))) || []) as (CommitQuickPickItem | CommandQuickPickItem)[]; + const items = ((stash && Array.from(Iterables.map(stash.commits.values(), c => new CommitQuickPickItem(c)))) || []) as (CommitQuickPickItem | CommandQuickPickItem)[]; if (goBackCommand) { items.splice(0, 0, goBackCommand);