mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-27 01:25:44 -05:00
Adds paging support to repo/file history quick picks (wip)
This commit is contained in:
@@ -3,7 +3,7 @@ import { commands, TextEditor, Uri, window } from 'vscode';
|
||||
import { ActiveEditorCommand, Commands } from './commands';
|
||||
import { GitProvider, GitUri, IGitLog } from '../gitProvider';
|
||||
import { Logger } from '../logger';
|
||||
import { CommandQuickPickItem, FileHistoryQuickPick } from '../quickPicks';
|
||||
import { CommandQuickPickItem, FileHistoryQuickPick, showQuickPickProgress } from '../quickPicks';
|
||||
import * as path from 'path';
|
||||
|
||||
export class ShowQuickFileHistoryCommand extends ActiveEditorCommand {
|
||||
@@ -27,13 +27,16 @@ export class ShowQuickFileHistoryCommand extends ActiveEditorCommand {
|
||||
maxCount = this.git.config.advanced.maxQuickHistory;
|
||||
}
|
||||
|
||||
const progressCancellation = showQuickPickProgress(`Loading file history \u2014 ${maxCount ? ` limited to ${maxCount} commits` : ` this may take a while`}\u2026`);
|
||||
try {
|
||||
if (!log) {
|
||||
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 pick = await FileHistoryQuickPick.show(log, uri, gitUri.sha, maxCount, this.git.config.advanced.maxQuickHistory, goBackCommand);
|
||||
if (progressCancellation.token.isCancellationRequested) return undefined;
|
||||
|
||||
const pick = await FileHistoryQuickPick.show(log, uri, gitUri.sha, progressCancellation, goBackCommand);
|
||||
if (!pick) return undefined;
|
||||
|
||||
if (pick instanceof CommandQuickPickItem) {
|
||||
@@ -52,5 +55,8 @@ export class ShowQuickFileHistoryCommand extends ActiveEditorCommand {
|
||||
Logger.error('[GitLens.ShowQuickFileHistoryCommand]', 'getLogLocations', ex);
|
||||
return window.showErrorMessage(`Unable to show file history. See output channel for more details`);
|
||||
}
|
||||
finally {
|
||||
progressCancellation.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import { commands, TextEditor, Uri, window } from 'vscode';
|
||||
import { ActiveEditorCommand, Commands } from './commands';
|
||||
import { GitProvider, GitUri, IGitLog } from '../gitProvider';
|
||||
import { Logger } from '../logger';
|
||||
import { CommandQuickPickItem, RepoHistoryQuickPick } from '../quickPicks';
|
||||
import { CommandQuickPickItem, RepoHistoryQuickPick, showQuickPickProgress } from '../quickPicks';
|
||||
|
||||
export class ShowQuickRepoHistoryCommand extends ActiveEditorCommand {
|
||||
|
||||
@@ -11,7 +11,7 @@ export class ShowQuickRepoHistoryCommand extends ActiveEditorCommand {
|
||||
super(Commands.ShowQuickRepoHistory);
|
||||
}
|
||||
|
||||
async execute(editor: TextEditor, uri?: Uri, maxCount?: number, goBackCommand?: CommandQuickPickItem, log?: IGitLog) {
|
||||
async execute(editor: TextEditor, uri?: Uri, sha?: string, maxCount?: number | undefined, goBackCommand?: CommandQuickPickItem, log?: IGitLog) {
|
||||
if (!(uri instanceof Uri)) {
|
||||
uri = editor && editor.document && editor.document.uri;
|
||||
}
|
||||
@@ -20,16 +20,21 @@ export class ShowQuickRepoHistoryCommand extends ActiveEditorCommand {
|
||||
maxCount = this.git.config.advanced.maxQuickHistory;
|
||||
}
|
||||
|
||||
const progressCancellation = showQuickPickProgress(`Loading repository history \u2014 ${maxCount ? ` limited to ${maxCount} commits` : ` this may take a while`}\u2026`);
|
||||
try {
|
||||
if (!log) {
|
||||
const repoPath = await this.git.getRepoPathFromUri(uri, this.repoPath);
|
||||
if (!repoPath) return window.showWarningMessage(`Unable to show repository history`);
|
||||
|
||||
log = await this.git.getLogForRepo(repoPath, undefined, maxCount);
|
||||
if (progressCancellation.token.isCancellationRequested) return undefined;
|
||||
|
||||
log = await this.git.getLogForRepo(repoPath, sha, maxCount);
|
||||
if (!log) return window.showWarningMessage(`Unable to show repository history`);
|
||||
}
|
||||
|
||||
const pick = await RepoHistoryQuickPick.show(log, uri, maxCount, this.git.config.advanced.maxQuickHistory, goBackCommand);
|
||||
if (progressCancellation.token.isCancellationRequested) return undefined;
|
||||
|
||||
const pick = await RepoHistoryQuickPick.show(log, uri, sha, progressCancellation, goBackCommand);
|
||||
if (!pick) return undefined;
|
||||
|
||||
if (pick instanceof CommandQuickPickItem) {
|
||||
@@ -40,12 +45,15 @@ export class ShowQuickRepoHistoryCommand extends ActiveEditorCommand {
|
||||
new CommandQuickPickItem({
|
||||
label: `go back \u21A9`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 to repository history`
|
||||
}, Commands.ShowQuickRepoHistory, [uri, maxCount, goBackCommand, log]),
|
||||
}, Commands.ShowQuickRepoHistory, [uri, sha, maxCount, goBackCommand, log]),
|
||||
log);
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.ShowQuickRepoHistoryCommand]', ex);
|
||||
return window.showErrorMessage(`Unable to show repository history. See output channel for more details`);
|
||||
}
|
||||
finally {
|
||||
progressCancellation.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user