mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-05 01:35:37 -05:00
Adds working filename detection method
Adds get current branch method Fixes diff with working tree when file was renamed Fixes various quick pick commands when file was renamed Adds branch support to ShowQuickRepoHistory Adds branch info to repo quick pick placeholder Adds Show Branch History to commit limited branch history quick pick Adds Show File History to commit limited file history quick pick Removes conditional display of commit details on commit file details quick pick Removes conditional display of show file history on commit file details quick pick Fixed #30 - Diff with Working Tree fails from repo/commit quickpick list if file was renamed (and the commit was before the rename)
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import { Iterables } from '../system';
|
||||
import { CancellationTokenSource, QuickPickOptions, Uri, window } from 'vscode';
|
||||
import { Commands, Keyboard, KeyNoopCommand } from '../commands';
|
||||
import { GitUri, IGitLog } from '../gitService';
|
||||
import { GitService, GitUri, IGitLog } from '../gitService';
|
||||
import { CommitQuickPickItem } from './gitQuickPicks';
|
||||
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, showQuickPickProgress } from './quickPicks';
|
||||
import * as path from 'path';
|
||||
@@ -10,7 +10,7 @@ import * as path from 'path';
|
||||
export class FileHistoryQuickPick {
|
||||
|
||||
static showProgress(uri: GitUri) {
|
||||
return showQuickPickProgress(`${uri.getFormattedPath()}${uri.sha ? ` \u00a0\u2022\u00a0 ${uri.sha.substring(0, 8)}` : ''}`,
|
||||
return showQuickPickProgress(`${uri.getFormattedPath()}${uri.sha ? ` \u00a0\u2022\u00a0 ${uri.shortSha}` : ''}`,
|
||||
{
|
||||
left: KeyNoopCommand,
|
||||
',': KeyNoopCommand,
|
||||
@@ -18,18 +18,38 @@ export class FileHistoryQuickPick {
|
||||
});
|
||||
}
|
||||
|
||||
static async show(log: IGitLog, uri: GitUri, progressCancellation: CancellationTokenSource, goBackCommand?: CommandQuickPickItem, nextPageCommand?: CommandQuickPickItem): Promise<CommitQuickPickItem | CommandQuickPickItem | undefined> {
|
||||
static async show(git: GitService, log: IGitLog, uri: GitUri, progressCancellation: CancellationTokenSource, goBackCommand?: CommandQuickPickItem, nextPageCommand?: CommandQuickPickItem): Promise<CommitQuickPickItem | CommandQuickPickItem | undefined> {
|
||||
const items = Array.from(Iterables.map(log.commits.values(), c => new CommitQuickPickItem(c))) as (CommitQuickPickItem | CommandQuickPickItem)[];
|
||||
|
||||
let previousPageCommand: CommandQuickPickItem;
|
||||
|
||||
let index = 0;
|
||||
if (log.truncated || uri.sha) {
|
||||
index++;
|
||||
items.splice(0, 0, new CommandQuickPickItem({
|
||||
label: `$(sync) Show All Commits`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 this may take a while`
|
||||
}, Commands.ShowQuickFileHistory, [Uri.file(uri.fsPath), undefined, 0, goBackCommand]));
|
||||
if (log.truncated) {
|
||||
index++;
|
||||
items.splice(0, 0, new CommandQuickPickItem({
|
||||
label: `$(sync) Show All Commits`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 this may take a while`
|
||||
}, Commands.ShowQuickFileHistory, [Uri.file(uri.fsPath), undefined, 0, goBackCommand]));
|
||||
}
|
||||
else {
|
||||
const workingFileName = await git.findWorkingFileName(log.repoPath, path.relative(log.repoPath, uri.fsPath));
|
||||
if (workingFileName) {
|
||||
index++;
|
||||
items.splice(0, 0, new CommandQuickPickItem({
|
||||
label: `$(history) Show File History`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 of ${path.basename(workingFileName)}`
|
||||
}, Commands.ShowQuickFileHistory, [
|
||||
Uri.file(path.resolve(log.repoPath, workingFileName)),
|
||||
undefined,
|
||||
undefined,
|
||||
new CommandQuickPickItem({
|
||||
label: `go back \u21A9`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 to history of \u00a0$(file-text) ${path.basename(uri.fsPath)}${uri.sha ? ` from \u00a0$(git-commit) ${uri.shortSha}` : ''}`
|
||||
}, Commands.ShowQuickFileHistory, [uri, log.range, log.maxCount, goBackCommand, log])
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
if (nextPageCommand) {
|
||||
index++;
|
||||
@@ -61,12 +81,13 @@ export class FileHistoryQuickPick {
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 shows the current branch history`
|
||||
}, Commands.ShowQuickRepoHistory,
|
||||
[
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
new CommandQuickPickItem({
|
||||
label: `go back \u21A9`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 to history of \u00a0$(file-text) ${path.basename(uri.fsPath)}`
|
||||
}, Commands.ShowQuickFileHistory, [uri, undefined, log.maxCount, undefined, log])
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 to history of \u00a0$(file-text) ${path.basename(uri.fsPath)}${uri.sha ? ` from \u00a0$(git-commit) ${uri.shortSha}` : ''}`
|
||||
}, Commands.ShowQuickFileHistory, [uri, log.range, log.maxCount, undefined, log])
|
||||
]));
|
||||
}
|
||||
|
||||
@@ -89,7 +110,7 @@ export class FileHistoryQuickPick {
|
||||
const pick = await window.showQuickPick(items, {
|
||||
matchOnDescription: true,
|
||||
matchOnDetail: true,
|
||||
placeHolder: `${commit.getFormattedPath()}${uri.sha ? ` \u00a0\u2022\u00a0 ${uri.sha.substring(0, 8)}` : ''}`,
|
||||
placeHolder: `${commit.getFormattedPath()}${uri.sha ? ` \u00a0\u2022\u00a0 ${uri.shortSha}` : ''}`,
|
||||
ignoreFocusOut: getQuickPickIgnoreFocusOut()
|
||||
// onDidSelectItem: (item: QuickPickItem) => {
|
||||
// scope.setKeyCommand('right', item);
|
||||
|
||||
Reference in New Issue
Block a user