Sfoglia il codice sorgente

Refactors the quickpick menus

Consolidated lots of duplicate functionality
go back navigation should be robust now
main
Eric Amodio 7 anni fa
parent
commit
8594a5dd38
6 ha cambiato i file con 238 aggiunte e 272 eliminazioni
  1. +15
    -17
      src/commands/quickPickItems.ts
  2. +132
    -0
      src/commands/quickPicks.ts
  3. +56
    -74
      src/commands/showQuickCommitDetails.ts
  4. +15
    -68
      src/commands/showQuickFileHistory.ts
  5. +19
    -112
      src/commands/showQuickRepoHistory.ts
  6. +1
    -1
      src/git/gitUri.ts

+ 15
- 17
src/commands/quickPickItems.ts Vedi File

@ -1,13 +1,22 @@
'use strict';
import { QuickPickItem, Uri } from 'vscode';
import { commands, QuickPickItem, Uri } from 'vscode';
import { Commands } from '../constants';
import { GitCommit, GitUri } from '../gitProvider';
import * as moment from 'moment';
import * as path from 'path';
export interface CommandQuickPickItem extends QuickPickItem {
command: Commands;
args?: any[];
export class CommandQuickPickItem implements QuickPickItem {
label: string;
description: string;
detail: string;
constructor(item: QuickPickItem, public command: Commands, public args?: any[]) {
Object.assign(this, item);
}
execute() {
return commands.executeCommand(this.command, ...(this.args || []));
}
}
export class CommitQuickPickItem implements QuickPickItem {
@ -28,25 +37,14 @@ export class FileQuickPickItem implements QuickPickItem {
label: string;
description: string;
detail: string;
sha: string;
uri: GitUri;
constructor(commit: GitCommit, public fileName: string) {
this.label = fileName;
this.sha = commit.sha;
this.uri = GitUri.fromUri(Uri.file(path.resolve(commit.repoPath, fileName)));
}
}
export class ShowAllCommitsQuickPickItem implements QuickPickItem {
label: string;
description: string;
detail: string;
constructor(maxItems: number) {
this.label = `$(sync) Show Full History`;
this.description = `\u2014 Currently only showing the first ${maxItems} commits`;
this.detail = `This may take a while`;
}
}

+ 132
- 0
src/commands/quickPicks.ts Vedi File

@ -0,0 +1,132 @@
'use strict';
import { Iterables } from '../system';
import { QuickPickOptions, Uri, window } from 'vscode';
import { Commands } from '../constants';
import { GitCommit, GitUri, IGitLog } from '../gitProvider';
import { CommandQuickPickItem, CommitQuickPickItem, FileQuickPickItem } from './quickPickItems';
import * as moment from 'moment';
import * as path from 'path';
export class CommitQuickPick {
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[] = [
new CommandQuickPickItem({
label: `$(diff) Compare with Working Tree`,
description: `$(git-commit) ${commit.sha} \u00a0 $(git-compare) \u00a0 $(file-text) ${workingFileName || commit.fileName}`
}, Commands.DiffWithWorking, [uri, commit])
];
if (commit.previousSha) {
items.push(new CommandQuickPickItem({
label: `$(diff) Compare with Previous Commit`,
description: `$(git-commit) ${commit.previousSha} \u00a0 $(git-compare) \u00a0 $(git-commit) ${commit.sha}`
}, Commands.DiffWithPrevious, [commit.uri, commit]));
}
if (options.showFileHistory) {
items.push(new CommandQuickPickItem({
label: `$(versions) Show History of ${fileName}`,
description: `\u2022 since $(git-commit) ${commit.sha}`
}, Commands.ShowQuickFileHistory, [new GitUri(commit.uri, commit), undefined, currentCommand]));
if (workingFileName) {
items.push(new CommandQuickPickItem({
label: `$(versions) Show Full History of ${fileName}`,
description: null
}, Commands.ShowQuickFileHistory, [commit.uri, undefined, currentCommand]));
}
}
if (goBackCommand) {
items.splice(0, 0, goBackCommand);
}
return await window.showQuickPick(items, {
matchOnDescription: true,
placeHolder: `${commit.fileName} \u2022 ${commit.sha} \u2022 ${commit.author}, ${moment(commit.date).fromNow()} \u2022 ${commit.message}`
} as QuickPickOptions);
}
}
export class CommitFilesQuickPick {
static async show(commit: GitCommit, uri: Uri, goBackCommand?: CommandQuickPickItem): Promise<FileQuickPickItem | CommandQuickPickItem | undefined> {
const items: (FileQuickPickItem | CommandQuickPickItem)[] = commit.fileName
.split(', ')
.filter(_ => !!_)
.map(f => new FileQuickPickItem(commit, f));
if (goBackCommand) {
items.splice(0, 0, goBackCommand);
}
return await window.showQuickPick(items, {
matchOnDescription: true,
matchOnDetail: true,
placeHolder: `${commit.sha} \u2022 ${commit.author}, ${moment(commit.date).fromNow()} \u2022 ${commit.message}`
} as QuickPickOptions);
}
}
export class FileCommitsQuickPick {
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)[];
// Only show the full repo option if we are the root
if (!goBackCommand) {
items.splice(0, 0, new CommandQuickPickItem({
label: `$(repo) Show Repository History`,
description: null
}, Commands.ShowQuickRepoHistory, [undefined, undefined, undefined, new CommandQuickPickItem({
label: `go back \u21A9`,
description: null
}, 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) {
items.splice(0, 0, goBackCommand);
}
return await window.showQuickPick(items, {
matchOnDescription: true,
matchOnDetail: true,
placeHolder: `${Iterables.first(log.commits.values()).fileName}`
} as QuickPickOptions);
}
}
export class RepoCommitsQuickPick {
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)[];
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.ShowQuickRepoHistory, [uri, 0, undefined, goBackCommand]));
}
if (goBackCommand) {
items.splice(0, 0, goBackCommand);
}
return await window.showQuickPick(items, {
matchOnDescription: true,
matchOnDetail: true,
placeHolder: 'Search by commit message, filename, or sha'
} as QuickPickOptions);
}
}

+ 56
- 74
src/commands/showQuickCommitDetails.ts Vedi File

@ -1,12 +1,12 @@
'use strict';
import { Iterables } from '../system';
import { commands, QuickPickOptions, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import { TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import { EditorCommand } from './commands';
import { Commands } from '../constants';
import GitProvider, { GitUri } from '../gitProvider';
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
import { Logger } from '../logger';
import { CommandQuickPickItem, CommitQuickPickItem, FileQuickPickItem } from './quickPickItems';
import * as moment from 'moment';
import { CommandQuickPickItem, FileQuickPickItem } from './quickPickItems';
import { CommitQuickPick, CommitFilesQuickPick } from './quickPicks';
export default class ShowQuickCommitDetailsCommand extends EditorCommand {
@ -14,7 +14,7 @@ export default class ShowQuickCommitDetailsCommand extends EditorCommand {
super(Commands.ShowQuickCommitDetails);
}
async execute(editor: TextEditor, edit: TextEditorEdit, uri?: Uri, sha?: string) {
async execute(editor: TextEditor, edit: TextEditorEdit, uri?: Uri, sha?: string, commit?: GitCommit, goBackCommand?: CommandQuickPickItem, options: { showFileHistory?: boolean } = { showFileHistory: true }) {
if (!(uri instanceof Uri)) {
if (!editor.document) return undefined;
uri = editor.document.uri;
@ -43,78 +43,60 @@ export default class ShowQuickCommitDetailsCommand extends EditorCommand {
}
try {
let log = await this.git.getLogForRepo(repoPath, sha, 0);
if (!log) return window.showWarningMessage(`Unable to show commit details`);
let commit = Iterables.first(log.commits.values());
const commitPick = new CommitQuickPickItem(commit, ` \u2014 ${commit.fileName}`);
const files = commitPick.commit.fileName
.split(', ')
.filter(_ => !!_)
.map(f => new FileQuickPickItem(commitPick.commit, f));
const filePick = await window.showQuickPick(files, {
matchOnDescription: true,
matchOnDetail: true,
placeHolder: `${commitPick.commit.sha} \u2022 ${commitPick.commit.author}, ${moment(commitPick.commit.date).fromNow()} \u2022 ${commitPick.commit.message}`
} as QuickPickOptions);
if (!filePick) return undefined;
// Get the most recent commit -- so that we can find the real working filename if there was a rename
const workingCommit = await this.git.findMostRecentCommitForFile(filePick.uri.fsPath, filePick.sha);
log = await this.git.getLogForFile(filePick.uri.fsPath, filePick.sha, undefined, undefined, 2);
if (!log) return window.showWarningMessage(`Unable to open diff`);
commit = Iterables.find(log.commits.values(), c => c.sha === commitPick.commit.sha);
const items: CommandQuickPickItem[] = [
{
label: `$(diff) Compare with Working Tree`,
description: `$(git-commit) ${commit.sha} \u00a0 $(git-compare) \u00a0 $(file-text) ${(workingCommit || commit).fileName}`,
command: Commands.DiffWithWorking,
args: [commit.uri, commit]
let pick: FileQuickPickItem | CommandQuickPickItem;
let alreadyPickedCommit = !!commit;
let workingFileName: string;
if (!alreadyPickedCommit) {
let log = await this.git.getLogForRepo(repoPath, sha, 0);
if (!log) return window.showWarningMessage(`Unable to show commit details`);
commit = Iterables.first(log.commits.values());
pick = await CommitFilesQuickPick.show(commit, uri, goBackCommand);
if (!pick) return undefined;
if (pick instanceof CommandQuickPickItem) {
return pick.execute();
}
];
if (commit.previousSha) {
items.push({
label: `$(diff) Compare with Previous Commit`,
description: `$(git-commit) ${commit.previousSha} \u00a0 $(git-compare) \u00a0 $(git-commit) ${commit.sha}`,
command: Commands.DiffWithPrevious,
args: [commit.uri, commit]
});
// Attempt to the most recent commit -- so that we can find the real working filename if there was a rename
const workingCommit = await this.git.findMostRecentCommitForFile(pick.uri.fsPath, pick.sha);
// TODO: Leave this at undefined until findMostRecentCommitForFile actually works
workingFileName = !workingCommit ? pick.fileName : undefined;
log = await this.git.getLogForFile(pick.uri.fsPath, pick.sha, undefined, undefined, 2);
if (!log) return window.showWarningMessage(`Unable to open diff`);
commit = Iterables.find(log.commits.values(), c => c.sha === commit.sha);
uri = pick.uri || uri;
}
else {
// Attempt to the most recent commit -- so that we can find the real working filename if there was a rename
const workingCommit = await this.git.findMostRecentCommitForFile(commit.uri.fsPath, commit.sha);
// TODO: Leave this at undefined until findMostRecentCommitForFile actually works
workingFileName = !workingCommit ? commit.fileName : undefined;
}
items.push({
label: `$(versions) Show History of ${commit.fileName}`,
description: `\u2022 since $(git-commit) ${commit.sha}`,
command: Commands.ShowQuickFileHistory,
args: [new GitUri(commit.uri, commit)]
} as CommandQuickPickItem);
items.push({
label: `$(versions) Show Full History of ${commit.fileName}`,
command: Commands.ShowQuickFileHistory,
description: `\u2022 this could fail if the file was renamed`,
args: [commit.uri] // TODO: This won't work for renames
} as CommandQuickPickItem);
items.push({
label: `$(reply) go back \u21A9`,
description: null,
command: Commands.ShowQuickCommitDetails,
args: [uri]
} as CommandQuickPickItem);
const commandPick = await window.showQuickPick(items, {
matchOnDescription: true,
placeHolder: `${commit.fileName} \u2022 ${commit.sha} \u2022 ${commit.author}, ${moment(commit.date).fromNow()} \u2022 ${commit.message}`
} as QuickPickOptions);
if (commandPick) {
return commands.executeCommand(commandPick.command, ...(commandPick.args || []));
pick = await CommitQuickPick.show(commit, workingFileName, uri,
// Create a command to get back to where we are right now
new CommandQuickPickItem({
label: `go back \u21A9`,
description: null
}, Commands.ShowQuickCommitDetails, [new GitUri(commit.uri, commit), sha, commit, goBackCommand, options]),
// If we have already picked a commit, just jump back to the previous (since we skipped a quickpick menu)
// Otherwise setup a normal back command
alreadyPickedCommit
? goBackCommand
: new CommandQuickPickItem({
label: `go back \u21A9`,
description: null
}, Commands.ShowQuickCommitDetails, [new GitUri(commit.uri, commit), sha, undefined, goBackCommand, options]),
{ showFileHistory: options.showFileHistory });
if (!pick) return undefined;
if (pick instanceof CommandQuickPickItem) {
return pick.execute();
}
return undefined;

+ 15
- 68
src/commands/showQuickFileHistory.ts Vedi File

@ -1,12 +1,11 @@
'use strict';
import { Iterables } from '../system';
import { commands, QuickPickItem, QuickPickOptions, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import { commands, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import { EditorCommand } from './commands';
import { Commands } from '../constants';
import GitProvider, { GitUri } from '../gitProvider';
import { Logger } from '../logger';
import { CommandQuickPickItem, CommitQuickPickItem, ShowAllCommitsQuickPickItem } from './quickPickItems';
import * as moment from 'moment';
import { CommandQuickPickItem } from './quickPickItems';
import { FileCommitsQuickPick } from './quickPicks';
export default class ShowQuickFileHistoryCommand extends EditorCommand {
@ -14,7 +13,7 @@ export default class ShowQuickFileHistoryCommand extends EditorCommand {
super(Commands.ShowQuickFileHistory);
}
async execute(editor: TextEditor, edit: TextEditorEdit, uri?: Uri, maxCount?: number) {
async execute(editor: TextEditor, edit: TextEditorEdit, uri?: Uri, maxCount?: number, goBackCommand?: CommandQuickPickItem) {
if (!(uri instanceof Uri)) {
if (!editor.document) return undefined;
uri = editor.document.uri;
@ -30,73 +29,21 @@ export default class ShowQuickFileHistoryCommand extends EditorCommand {
const log = await this.git.getLogForFile(gitUri.fsPath, gitUri.sha, gitUri.repoPath, undefined, maxCount);
if (!log) return window.showWarningMessage(`Unable to show file history. File is probably not under source control`);
const commits = Array.from(Iterables.map(log.commits.values(), c => new CommitQuickPickItem(c))) as QuickPickItem[];
if (maxCount !== 0 && commits.length === this.git.config.advanced.maxQuickHistory) {
commits.splice(0, 0, new ShowAllCommitsQuickPickItem(this.git.config.advanced.maxQuickHistory));
}
commits.splice(0, 0, {
label: `$(repo) Show Repository History`,
command: Commands.ShowQuickRepoHistory
} as CommandQuickPickItem);
const pick = await window.showQuickPick(commits, {
matchOnDescription: true,
matchOnDetail: true,
placeHolder: `${Iterables.first(log.commits.values()).fileName}`
} as QuickPickOptions);
let pick = await FileCommitsQuickPick.show(log, uri, maxCount, this.git.config.advanced.maxQuickHistory, goBackCommand);
if (!pick) return undefined;
if (pick instanceof ShowAllCommitsQuickPickItem) {
return commands.executeCommand(Commands.ShowQuickFileHistory, uri, 0);
}
if (!(pick instanceof CommitQuickPickItem)) {
const commandPick = pick && pick as CommandQuickPickItem;
if (commandPick) {
return commands.executeCommand(commandPick.command, ...(commandPick.args || []));
}
}
const commitPick = pick as CommitQuickPickItem;
const commit = commitPick.commit;
const items: CommandQuickPickItem[] = [
{
label: `$(diff) Compare with Working Tree`,
description: `$(git-commit) ${commit.sha} \u00a0 $(git-compare) \u00a0 $(file-text) ${commit.fileName}`,
command: Commands.DiffWithWorking,
args: [commit.uri, commit]
}
];
if (commit.previousSha) {
items.push({
label: `$(diff) Compare with Previous Commit`,
description: `$(git-commit) ${commit.previousSha} \u00a0 $(git-compare) \u00a0 $(git-commit) ${commit.sha}`,
command: Commands.DiffWithPrevious,
args: [commit.uri, commit]
});
}
items.push({
label: `go back \u21A9`,
description: null,
command: Commands.ShowQuickFileHistory,
args: [uri, maxCount]
} as CommandQuickPickItem);
const commandPick = await window.showQuickPick(items, {
matchOnDescription: true,
placeHolder: `${commit.fileName} \u2022 ${commit.sha} \u2022 ${commit.author}, ${moment(commit.date).fromNow()} \u2022 ${commit.message}`
} as QuickPickOptions);
if (commandPick) {
return commands.executeCommand(commandPick.command, ...(commandPick.args || []));
if (pick instanceof CommandQuickPickItem) {
return pick.execute();
}
return undefined;
return commands.executeCommand(Commands.ShowQuickCommitDetails,
new GitUri(pick.commit.uri, pick.commit),
pick.commit.sha, pick.commit,
new CommandQuickPickItem({
label: `go back \u21A9`,
description: null
}, Commands.ShowQuickFileHistory, [uri, maxCount, goBackCommand]),
{ showFileHistory: false });
}
catch (ex) {
Logger.error('[GitLens.ShowQuickFileHistoryCommand]', 'getLogLocations', ex);

+ 19
- 112
src/commands/showQuickRepoHistory.ts Vedi File

@ -1,12 +1,11 @@
'use strict';
import { Iterables } from '../system';
import { commands, QuickPickItem, QuickPickOptions, Uri, window } from 'vscode';
import { commands, Uri, window } from 'vscode';
import { Command } from './commands';
import { Commands } from '../constants';
import GitProvider, { GitUri } from '../gitProvider';
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
import { Logger } from '../logger';
import { CommandQuickPickItem, CommitQuickPickItem, FileQuickPickItem, ShowAllCommitsQuickPickItem } from './quickPickItems';
import * as moment from 'moment';
import { CommandQuickPickItem } from './quickPickItems';
import { RepoCommitsQuickPick } from './quickPicks';
export default class ShowQuickRepoHistoryCommand extends Command {
@ -14,7 +13,7 @@ export default class ShowQuickRepoHistoryCommand extends Command {
super(Commands.ShowQuickRepoHistory);
}
async execute(uri?: Uri, maxCount?: number, commitPick?: CommitQuickPickItem) {
async execute(uri?: Uri, maxCount?: number, commit?: GitCommit, goBackCommand?: CommandQuickPickItem) {
if (!(uri instanceof Uri)) {
const document = window.activeTextEditor && window.activeTextEditor.document;
if (document) {
@ -40,121 +39,29 @@ export default class ShowQuickRepoHistoryCommand extends Command {
if (!repoPath) {
repoPath = this.repoPath;
}
if (!repoPath) return window.showWarningMessage(`Unable to show repository history`);
let log = await this.git.getLogForRepo(repoPath, undefined, maxCount);
if (!log) return window.showWarningMessage(`Unable to show repository history`);
const commits = Array.from(Iterables.map(log.commits.values(), c => new CommitQuickPickItem(c, ` \u2014 ${c.fileName}`))) as QuickPickItem[];
let placeHolder = 'Search by commit message, filename, or sha';
if (maxCount !== 0 && commits.length === this.git.config.advanced.maxQuickHistory) {
// placeHolder += `; Only showing the first ${this.git.config.advanced.maxQuickHistory} commits`;
// commits.push(new ShowAllCommitsQuickPickItem(this.git.config.advanced.maxQuickHistory));
commits.splice(0, 0, new ShowAllCommitsQuickPickItem(this.git.config.advanced.maxQuickHistory));
}
let pick: QuickPickItem;
if (!commitPick) {
pick = await window.showQuickPick(commits, {
matchOnDescription: true,
matchOnDetail: true,
placeHolder: placeHolder
} as QuickPickOptions);
if (!commit) {
const log = await this.git.getLogForRepo(this.repoPath, undefined, maxCount);
if (!log) return window.showWarningMessage(`Unable to show repository history`);
const pick = await RepoCommitsQuickPick.show(log, uri, maxCount, this.git.config.advanced.maxQuickHistory, goBackCommand);
if (!pick) return undefined;
if (pick instanceof ShowAllCommitsQuickPickItem) {
return commands.executeCommand(Commands.ShowQuickRepoHistory, uri, 0);
}
commitPick = pick as CommitQuickPickItem;
}
const files: (FileQuickPickItem | CommandQuickPickItem)[] = commitPick.commit.fileName
.split(', ')
.filter(_ => !!_)
.map(f => new FileQuickPickItem(commitPick.commit, f));
files.push({
label: `go back \u21A9`,
description: null,
command: Commands.ShowQuickRepoHistory,
args: [uri, maxCount]
} as CommandQuickPickItem);
pick = await window.showQuickPick(files, {
matchOnDescription: true,
matchOnDetail: true,
placeHolder: `${commitPick.commit.sha} \u2022 ${commitPick.commit.author}, ${moment(commitPick.commit.date).fromNow()}`
} as QuickPickOptions);
if (!pick) return undefined;
if (!(pick instanceof FileQuickPickItem)) {
const commandPick = pick && pick as CommandQuickPickItem;
if (commandPick) {
return commands.executeCommand(commandPick.command, ...(commandPick.args || []));
if (pick instanceof CommandQuickPickItem) {
return pick.execute();
}
}
const filePick = pick as FileQuickPickItem;
// Get the most recent commit -- so that we can find the real working filename if there was a rename
const workingCommit = await this.git.findMostRecentCommitForFile(filePick.uri.fsPath, filePick.sha);
log = await this.git.getLogForFile(filePick.uri.fsPath, filePick.sha, undefined, undefined, 2);
if (!log) return window.showWarningMessage(`Unable to open diff`);
const commit = Iterables.find(log.commits.values(), c => c.sha === commitPick.commit.sha);
const items: CommandQuickPickItem[] = [
{
label: `$(diff) Compare with Working Tree`,
description: `$(git-commit) ${commit.sha} \u00a0 $(git-compare) \u00a0 $(file-text) ${(workingCommit || commit).fileName}`,
command: Commands.DiffWithWorking,
args: [commit.uri, commit]
}
];
if (commit.previousSha) {
items.push({
label: `$(diff) Compare with Previous Commit`,
description: `$(git-commit) ${commit.previousSha} \u00a0 $(git-compare) \u00a0 $(git-commit) ${commit.sha}`,
command: Commands.DiffWithPrevious,
args: [commit.uri, commit]
});
}
items.push({
label: `$(versions) Show History of ${commit.fileName}`,
description: `\u2022 since $(git-commit) ${commit.sha}`,
command: Commands.ShowQuickFileHistory,
args: [new GitUri(commit.uri, commit)]
} as CommandQuickPickItem);
items.push({
label: `$(versions) Show Full History of ${commit.fileName}`,
description: `\u2022 this could fail if the file was renamed`,
command: Commands.ShowQuickFileHistory,
args: [commit.uri] // TODO: This won't work for renames
} as CommandQuickPickItem);
items.push({
label: `go back \u21A9`,
description: null,
command: Commands.ShowQuickRepoHistory,
args: [uri, maxCount, commitPick]
} as CommandQuickPickItem);
const commandPick = await window.showQuickPick(items, {
matchOnDescription: true,
placeHolder: `${commit.fileName} \u2022 ${commit.sha} \u2022 ${commit.author}, ${moment(commit.date).fromNow()} \u2022 ${commit.message}`
} as QuickPickOptions);
if (commandPick) {
return commands.executeCommand(commandPick.command, ...(commandPick.args || []));
commit = pick.commit;
}
return undefined;
return commands.executeCommand(Commands.ShowQuickCommitDetails,
new GitUri(commit.uri, commit),
commit.sha, undefined,
new CommandQuickPickItem({
label: `go back \u21A9`,
description: null
}, Commands.ShowQuickRepoHistory, [uri, maxCount, undefined, goBackCommand]));
}
catch (ex) {
Logger.error('[GitLens.ShowQuickRepoHistoryCommand]', ex);

+ 1
- 1
src/git/gitUri.ts Vedi File

@ -38,7 +38,7 @@ export class GitUri extends Uri {
}
fileUri() {
return Uri.file(this.fsPath);
return Uri.file(this.sha ? this.path : this.fsPath);
}
static fromUri(uri: Uri, git?: GitProvider) {

Caricamento…
Annulla
Salva