Renames & changes some quickpicks for clarity

This commit is contained in:
Eric Amodio
2017-02-16 12:26:51 -05:00
parent b17c43ba9a
commit 51ef25f366

View File

@@ -5,13 +5,10 @@ import { Commands } from '../constants';
import { GitCommit, GitUri, IGitLog } from '../gitProvider'; import { GitCommit, GitUri, IGitLog } from '../gitProvider';
import { CommandQuickPickItem, CommitQuickPickItem, FileQuickPickItem } from './quickPickItems'; import { CommandQuickPickItem, CommitQuickPickItem, FileQuickPickItem } from './quickPickItems';
import * as moment from 'moment'; import * as moment from 'moment';
import * as path from 'path';
export class CommitQuickPick { export class CommitQuickPick {
static async show(commit: GitCommit, workingFileName: string, uri: Uri, currentCommand?: CommandQuickPickItem, goBackCommand?: CommandQuickPickItem, options: { showFileHistory?: boolean } = {}): Promise<CommandQuickPickItem | undefined> { static async show(commit: GitCommit, workingFileName: string, uri: Uri, currentCommand?: CommandQuickPickItem, goBackCommand?: CommandQuickPickItem, options: { showFileHistory?: boolean } = {}): Promise<CommandQuickPickItem | undefined> {
const fileName = path.basename(commit.fileName);
const items: CommandQuickPickItem[] = [ const items: CommandQuickPickItem[] = [
new CommandQuickPickItem({ new CommandQuickPickItem({
label: `$(diff) Compare with Working Tree`, label: `$(diff) Compare with Working Tree`,
@@ -28,14 +25,16 @@ export class CommitQuickPick {
if (options.showFileHistory) { if (options.showFileHistory) {
items.push(new CommandQuickPickItem({ items.push(new CommandQuickPickItem({
label: `$(versions) Show History of ${fileName}`, label: `$(versions) Show Previous Commit History`,
description: `\u2022 since $(git-commit) ${commit.sha}` description: `\u2022 ${commit.fileName}`,
detail: `Shows the previous commit history starting at $(git-commit) ${commit.sha}`
}, Commands.ShowQuickFileHistory, [new GitUri(commit.uri, commit), undefined, currentCommand])); }, Commands.ShowQuickFileHistory, [new GitUri(commit.uri, commit), undefined, currentCommand]));
if (workingFileName) { if (workingFileName) {
items.push(new CommandQuickPickItem({ items.push(new CommandQuickPickItem({
label: `$(versions) Show Full History of ${fileName}`, label: `$(versions) Show Commit History`,
description: null description: `\u2022 ${commit.fileName}`,
detail: `Shows the commit history starting at the most recent commit`
}, Commands.ShowQuickFileHistory, [commit.uri, undefined, currentCommand])); }, Commands.ShowQuickFileHistory, [commit.uri, undefined, currentCommand]));
} }
} }
@@ -76,25 +75,26 @@ export class FileCommitsQuickPick {
static async show(log: IGitLog, uri: Uri, maxCount: number, defaultMaxCount: number, goBackCommand?: CommandQuickPickItem): Promise<CommitQuickPickItem | CommandQuickPickItem | undefined> { static async show(log: IGitLog, uri: Uri, maxCount: number, defaultMaxCount: number, goBackCommand?: CommandQuickPickItem): Promise<CommitQuickPickItem | CommandQuickPickItem | undefined> {
const items = Array.from(Iterables.map(log.commits.values(), c => new CommitQuickPickItem(c))) as (CommitQuickPickItem | CommandQuickPickItem)[]; const items = Array.from(Iterables.map(log.commits.values(), c => new CommitQuickPickItem(c))) as (CommitQuickPickItem | CommandQuickPickItem)[];
if (maxCount !== 0 && items.length >= defaultMaxCount) {
items.splice(0, 0, new CommandQuickPickItem({
label: `$(sync) Show All Commits`,
description: `\u2014 Currently only showing the first ${defaultMaxCount} commits`,
detail: `This may take a while`
}, Commands.ShowQuickFileHistory, [uri, 0, goBackCommand]));
}
// Only show the full repo option if we are the root // Only show the full repo option if we are the root
if (!goBackCommand) { if (!goBackCommand) {
items.splice(0, 0, new CommandQuickPickItem({ items.splice(0, 0, new CommandQuickPickItem({
label: `$(repo) Show Repository History`, label: `$(repo) Show Repository History`,
description: null description: null,
detail: 'Shows the commit history of the repository'
}, Commands.ShowQuickRepoHistory, [undefined, undefined, undefined, new CommandQuickPickItem({ }, Commands.ShowQuickRepoHistory, [undefined, undefined, undefined, new CommandQuickPickItem({
label: `go back \u21A9`, label: `go back \u21A9`,
description: null description: null
}, Commands.ShowQuickFileHistory, [uri, maxCount])])); }, Commands.ShowQuickFileHistory, [uri, maxCount])]));
} }
if (maxCount !== 0 && items.length === defaultMaxCount) {
items.splice(0, 0, new CommandQuickPickItem({
label: `$(sync) Show Full History`,
description: `\u2014 Currently only showing the first ${defaultMaxCount} commits`,
detail: `This may take a while`
}, Commands.ShowQuickFileHistory, [uri, 0, goBackCommand]));
}
if (goBackCommand) { if (goBackCommand) {
items.splice(0, 0, goBackCommand); items.splice(0, 0, goBackCommand);
} }
@@ -111,9 +111,10 @@ export class RepoCommitsQuickPick {
static async show(log: IGitLog, uri: Uri, maxCount: number, defaultMaxCount: number, goBackCommand?: CommandQuickPickItem): Promise<CommitQuickPickItem | CommandQuickPickItem | undefined> { static async show(log: IGitLog, uri: Uri, maxCount: number, defaultMaxCount: number, goBackCommand?: CommandQuickPickItem): Promise<CommitQuickPickItem | CommandQuickPickItem | undefined> {
const items = Array.from(Iterables.map(log.commits.values(), c => new CommitQuickPickItem(c, ` \u2014 ${c.fileName}`))) as (CommitQuickPickItem | CommandQuickPickItem)[]; const items = Array.from(Iterables.map(log.commits.values(), c => new CommitQuickPickItem(c, ` \u2014 ${c.fileName}`))) as (CommitQuickPickItem | CommandQuickPickItem)[];
if (maxCount !== 0 && items.length === defaultMaxCount) {
if (maxCount !== 0 && items.length >= defaultMaxCount) {
items.splice(0, 0, new CommandQuickPickItem({ items.splice(0, 0, new CommandQuickPickItem({
label: `$(sync) Show Full History`, label: `$(sync) Show All Commits`,
description: `\u2014 Currently only showing the first ${defaultMaxCount} commits`, description: `\u2014 Currently only showing the first ${defaultMaxCount} commits`,
detail: `This may take a while` detail: `This may take a while`
}, Commands.ShowQuickRepoHistory, [uri, 0, undefined, goBackCommand])); }, Commands.ShowQuickRepoHistory, [uri, 0, undefined, goBackCommand]));