mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-16 18:48:45 -05:00
Adds diffWithRevision command
This commit is contained in:
@@ -103,6 +103,8 @@ GitLens provides an unobtrusive blame annotation at the end of the current line,
|
|||||||
|
|
||||||
- Adds a `Compare Line Commit with Previous` command (`gitlens.diffLineWithPrevious`) with a shortcut of `shift+alt+,` to compare the active file/diff with the previous line commit revision
|
- Adds a `Compare Line Commit with Previous` command (`gitlens.diffLineWithPrevious`) with a shortcut of `shift+alt+,` to compare the active file/diff with the previous line commit revision
|
||||||
|
|
||||||
|
- Adds a `Compare File with Revision...` command (`gitlens.diffWithRevision`) to compare the active file with the selected revision of the same file
|
||||||
|
|
||||||
- Adds a `Compare File with Working Tree` command (`gitlens.diffWithWorking`) with a shortcut of `shift+alt+w` to compare the most recent commit revision of the active file/diff with the working tree
|
- Adds a `Compare File with Working Tree` command (`gitlens.diffWithWorking`) with a shortcut of `shift+alt+w` to compare the most recent commit revision of the active file/diff with the working tree
|
||||||
|
|
||||||
- Adds a `Compare Line Commit with Working Tree` command (`gitlens.diffLineWithWorking`) with a shortcut of `alt+w` to compare the commit revision of the active line with the working tree
|
- Adds a `Compare Line Commit with Working Tree` command (`gitlens.diffLineWithWorking`) with a shortcut of `alt+w` to compare the commit revision of the active line with the working tree
|
||||||
|
|||||||
@@ -769,6 +769,11 @@
|
|||||||
"title": "Compare Line Commit with Previous",
|
"title": "Compare Line Commit with Previous",
|
||||||
"category": "GitLens"
|
"category": "GitLens"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "gitlens.diffWithRevision",
|
||||||
|
"title": "Compare File with Revision...",
|
||||||
|
"category": "GitLens"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "gitlens.diffWithWorking",
|
"command": "gitlens.diffWithWorking",
|
||||||
"title": "Compare File with Working Tree",
|
"title": "Compare File with Working Tree",
|
||||||
@@ -950,6 +955,10 @@
|
|||||||
"command": "gitlens.diffLineWithPrevious",
|
"command": "gitlens.diffLineWithPrevious",
|
||||||
"when": "gitlens:isBlameable"
|
"when": "gitlens:isBlameable"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "gitlens.diffWithRevision",
|
||||||
|
"when": "gitlens:isTracked"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "gitlens.diffWithWorking",
|
"command": "gitlens.diffWithWorking",
|
||||||
"when": "gitlens:isTracked"
|
"when": "gitlens:isTracked"
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ export * from './commands/diffLineWithWorking';
|
|||||||
export * from './commands/diffWithBranch';
|
export * from './commands/diffWithBranch';
|
||||||
export * from './commands/diffWithNext';
|
export * from './commands/diffWithNext';
|
||||||
export * from './commands/diffWithPrevious';
|
export * from './commands/diffWithPrevious';
|
||||||
|
export * from './commands/diffWithRevision';
|
||||||
export * from './commands/diffWithWorking';
|
export * from './commands/diffWithWorking';
|
||||||
export * from './commands/openChangedFiles';
|
export * from './commands/openChangedFiles';
|
||||||
export * from './commands/openBranchInRemote';
|
export * from './commands/openBranchInRemote';
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export type Commands = 'gitlens.closeUnchangedFiles' |
|
|||||||
'gitlens.diffWithNext' |
|
'gitlens.diffWithNext' |
|
||||||
'gitlens.diffWithPrevious' |
|
'gitlens.diffWithPrevious' |
|
||||||
'gitlens.diffLineWithPrevious' |
|
'gitlens.diffLineWithPrevious' |
|
||||||
|
'gitlens.diffWithRevision' |
|
||||||
'gitlens.diffWithWorking' |
|
'gitlens.diffWithWorking' |
|
||||||
'gitlens.diffLineWithWorking' |
|
'gitlens.diffLineWithWorking' |
|
||||||
'gitlens.openChangedFiles' |
|
'gitlens.openChangedFiles' |
|
||||||
@@ -49,6 +50,7 @@ export const Commands = {
|
|||||||
DiffWithNext: 'gitlens.diffWithNext' as Commands,
|
DiffWithNext: 'gitlens.diffWithNext' as Commands,
|
||||||
DiffWithPrevious: 'gitlens.diffWithPrevious' as Commands,
|
DiffWithPrevious: 'gitlens.diffWithPrevious' as Commands,
|
||||||
DiffLineWithPrevious: 'gitlens.diffLineWithPrevious' as Commands,
|
DiffLineWithPrevious: 'gitlens.diffLineWithPrevious' as Commands,
|
||||||
|
DiffWithRevision: 'gitlens.diffWithRevision' as Commands,
|
||||||
DiffWithWorking: 'gitlens.diffWithWorking' as Commands,
|
DiffWithWorking: 'gitlens.diffWithWorking' as Commands,
|
||||||
DiffLineWithWorking: 'gitlens.diffLineWithWorking' as Commands,
|
DiffLineWithWorking: 'gitlens.diffLineWithWorking' as Commands,
|
||||||
OpenChangedFiles: 'gitlens.openChangedFiles' as Commands,
|
OpenChangedFiles: 'gitlens.openChangedFiles' as Commands,
|
||||||
|
|||||||
81
src/commands/diffWithRevision.ts
Normal file
81
src/commands/diffWithRevision.ts
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
'use strict';
|
||||||
|
import { commands, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
|
||||||
|
import { ActiveEditorCommand, CommandContext, Commands, getCommandUri } from './common';
|
||||||
|
import { BuiltInCommands, GlyphChars } from '../constants';
|
||||||
|
import { GitService, GitUri } from '../gitService';
|
||||||
|
import { Logger } from '../logger';
|
||||||
|
import { Messages } from '../messages';
|
||||||
|
import { CommandQuickPickItem, FileHistoryQuickPick } from '../quickPicks';
|
||||||
|
import * as path from 'path';
|
||||||
|
|
||||||
|
export interface DiffWithRevisionCommandArgs {
|
||||||
|
line?: number;
|
||||||
|
maxCount?: number;
|
||||||
|
showOptions?: TextDocumentShowOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class DiffWithRevisionCommand extends ActiveEditorCommand {
|
||||||
|
|
||||||
|
constructor(private git: GitService) {
|
||||||
|
super(Commands.DiffWithRevision);
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(context: CommandContext, args: DiffWithRevisionCommandArgs = {}): Promise<any> {
|
||||||
|
// Since we can change the args and they could be cached -- make a copy
|
||||||
|
switch (context.type) {
|
||||||
|
case 'uri':
|
||||||
|
return this.execute(context.editor, context.uri, { ...args });
|
||||||
|
case 'scm-states':
|
||||||
|
const resource = context.scmResourceStates[0];
|
||||||
|
return this.execute(undefined, resource.resourceUri, { ...args });
|
||||||
|
case 'scm-groups':
|
||||||
|
return undefined;
|
||||||
|
default:
|
||||||
|
return this.execute(context.editor, undefined, { ...args });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async execute(editor: TextEditor | undefined, uri?: Uri, args: DiffWithRevisionCommandArgs = {}): Promise<any> {
|
||||||
|
uri = getCommandUri(uri, editor);
|
||||||
|
if (uri === undefined) return undefined;
|
||||||
|
|
||||||
|
if (args.line === undefined) {
|
||||||
|
args.line = editor === undefined ? 0 : editor.selection.active.line;
|
||||||
|
}
|
||||||
|
|
||||||
|
const gitUri = await GitUri.fromUri(uri, this.git);
|
||||||
|
if (args.maxCount == null) {
|
||||||
|
args.maxCount = this.git.config.advanced.maxQuickHistory;
|
||||||
|
}
|
||||||
|
|
||||||
|
const progressCancellation = FileHistoryQuickPick.showProgress(gitUri);
|
||||||
|
try {
|
||||||
|
const log = await this.git.getLogForFile(gitUri.repoPath, gitUri.fsPath, gitUri.sha, { maxCount: args.maxCount });
|
||||||
|
if (log === undefined) return Messages.showFileNotUnderSourceControlWarningMessage('Unable to open history compare');
|
||||||
|
|
||||||
|
if (progressCancellation.token.isCancellationRequested) return undefined;
|
||||||
|
|
||||||
|
const pick = await FileHistoryQuickPick.show(this.git, log, gitUri, progressCancellation, { pickerOnly: true });
|
||||||
|
if (pick === undefined) return undefined;
|
||||||
|
|
||||||
|
if (pick instanceof CommandQuickPickItem) return pick.execute();
|
||||||
|
|
||||||
|
const compare = await this.git.getVersionedFile(gitUri.repoPath, gitUri.fsPath, pick.commit.sha);
|
||||||
|
|
||||||
|
await commands.executeCommand(BuiltInCommands.Diff,
|
||||||
|
Uri.file(compare),
|
||||||
|
gitUri.fileUri(),
|
||||||
|
`${path.basename(gitUri.fsPath)} (${pick.commit.shortSha}) ${GlyphChars.ArrowLeftRight} ${path.basename(gitUri.fsPath)}`,
|
||||||
|
args.showOptions);
|
||||||
|
|
||||||
|
if (args.line === undefined || args.line === 0) return undefined;
|
||||||
|
|
||||||
|
// TODO: Figure out how to focus the left pane
|
||||||
|
return await commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: args.line, at: 'center' });
|
||||||
|
}
|
||||||
|
catch (ex) {
|
||||||
|
Logger.error(ex, 'DiffWithRevisionCommand', 'getVersionedFile');
|
||||||
|
return window.showErrorMessage(`Unable to open history compare. See output channel for more details`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,30 +1,30 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { Strings } from '../system';
|
import { Strings } from '../system';
|
||||||
import { commands, Range, TextEditor, Uri, window } from 'vscode';
|
import { commands, Range, TextEditor, Uri, window } from 'vscode';
|
||||||
import { ActiveEditorCachedCommand, CommandContext, Commands, getCommandUri } from './common';
|
import { ActiveEditorCachedCommand, CommandContext, Commands, getCommandUri } from './common';
|
||||||
import { GlyphChars } from '../constants';
|
import { GlyphChars } from '../constants';
|
||||||
import { GitLog, GitService, GitUri } from '../gitService';
|
import { GitLog, GitService, GitUri } from '../gitService';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import { CommandQuickPickItem, FileHistoryQuickPick } from '../quickPicks';
|
import { CommandQuickPickItem, FileHistoryQuickPick } from '../quickPicks';
|
||||||
import { ShowQuickCommitFileDetailsCommandArgs } from './showQuickCommitFileDetails';
|
import { ShowQuickCommitFileDetailsCommandArgs } from './showQuickCommitFileDetails';
|
||||||
import { Messages } from '../messages';
|
import { Messages } from '../messages';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
export interface ShowQuickFileHistoryCommandArgs {
|
export interface ShowQuickFileHistoryCommandArgs {
|
||||||
log?: GitLog;
|
log?: GitLog;
|
||||||
maxCount?: number;
|
maxCount?: number;
|
||||||
range?: Range;
|
range?: Range;
|
||||||
|
|
||||||
goBackCommand?: CommandQuickPickItem;
|
goBackCommand?: CommandQuickPickItem;
|
||||||
nextPageCommand?: CommandQuickPickItem;
|
nextPageCommand?: CommandQuickPickItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ShowQuickFileHistoryCommand extends ActiveEditorCachedCommand {
|
export class ShowQuickFileHistoryCommand extends ActiveEditorCachedCommand {
|
||||||
|
|
||||||
constructor(private git: GitService) {
|
constructor(private git: GitService) {
|
||||||
super(Commands.ShowQuickFileHistory);
|
super(Commands.ShowQuickFileHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
async run(context: CommandContext, args: ShowQuickFileHistoryCommandArgs = {}): Promise<any> {
|
async run(context: CommandContext, args: ShowQuickFileHistoryCommandArgs = {}): Promise<any> {
|
||||||
// Since we can change the args and they could be cached -- make a copy
|
// Since we can change the args and they could be cached -- make a copy
|
||||||
switch (context.type) {
|
switch (context.type) {
|
||||||
@@ -41,53 +41,53 @@ export class ShowQuickFileHistoryCommand extends ActiveEditorCachedCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async execute(editor: TextEditor | undefined, uri?: Uri, args: ShowQuickFileHistoryCommandArgs = {}) {
|
async execute(editor: TextEditor | undefined, uri?: Uri, args: ShowQuickFileHistoryCommandArgs = {}) {
|
||||||
uri = getCommandUri(uri, editor);
|
uri = getCommandUri(uri, editor);
|
||||||
if (uri === undefined) return commands.executeCommand(Commands.ShowQuickCurrentBranchHistory);
|
if (uri === undefined) return commands.executeCommand(Commands.ShowQuickCurrentBranchHistory);
|
||||||
|
|
||||||
const gitUri = await GitUri.fromUri(uri, this.git);
|
const gitUri = await GitUri.fromUri(uri, this.git);
|
||||||
|
|
||||||
if (args.maxCount == null) {
|
if (args.maxCount == null) {
|
||||||
args.maxCount = this.git.config.advanced.maxQuickHistory;
|
args.maxCount = this.git.config.advanced.maxQuickHistory;
|
||||||
}
|
}
|
||||||
|
|
||||||
const progressCancellation = FileHistoryQuickPick.showProgress(gitUri);
|
const progressCancellation = FileHistoryQuickPick.showProgress(gitUri);
|
||||||
try {
|
try {
|
||||||
if (args.log === undefined) {
|
if (args.log === undefined) {
|
||||||
args.log = await this.git.getLogForFile(gitUri.repoPath, gitUri.fsPath, gitUri.sha, { maxCount: args.maxCount, range: args.range });
|
args.log = await this.git.getLogForFile(gitUri.repoPath, gitUri.fsPath, gitUri.sha, { maxCount: args.maxCount, range: args.range });
|
||||||
if (args.log === undefined) return Messages.showFileNotUnderSourceControlWarningMessage('Unable to show file history');
|
if (args.log === undefined) return Messages.showFileNotUnderSourceControlWarningMessage('Unable to show file history');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (progressCancellation.token.isCancellationRequested) return undefined;
|
if (progressCancellation.token.isCancellationRequested) return undefined;
|
||||||
|
|
||||||
const pick = await FileHistoryQuickPick.show(this.git, args.log, gitUri, progressCancellation, args.goBackCommand, args.nextPageCommand);
|
const pick = await FileHistoryQuickPick.show(this.git, args.log, gitUri, progressCancellation, { goBackCommand: args.goBackCommand, nextPageCommand: args.nextPageCommand });
|
||||||
if (pick === undefined) return undefined;
|
if (pick === undefined) return undefined;
|
||||||
|
|
||||||
if (pick instanceof CommandQuickPickItem) return pick.execute();
|
if (pick instanceof CommandQuickPickItem) return pick.execute();
|
||||||
|
|
||||||
// Create a command to get back to where we are right now
|
// Create a command to get back to where we are right now
|
||||||
const currentCommand = new CommandQuickPickItem({
|
const currentCommand = new CommandQuickPickItem({
|
||||||
label: `go back ${GlyphChars.ArrowBack}`,
|
label: `go back ${GlyphChars.ArrowBack}`,
|
||||||
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} to history of ${GlyphChars.Space}$(file-text) ${path.basename(pick.commit.fileName)}${gitUri.sha ? ` from ${GlyphChars.Space}$(git-commit) ${gitUri.shortSha}` : ''}`
|
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} to history of ${GlyphChars.Space}$(file-text) ${path.basename(pick.commit.fileName)}${gitUri.sha ? ` from ${GlyphChars.Space}$(git-commit) ${gitUri.shortSha}` : ''}`
|
||||||
}, Commands.ShowQuickFileHistory, [
|
}, Commands.ShowQuickFileHistory, [
|
||||||
uri,
|
uri,
|
||||||
args
|
args
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return commands.executeCommand(Commands.ShowQuickCommitFileDetails,
|
return commands.executeCommand(Commands.ShowQuickCommitFileDetails,
|
||||||
new GitUri(pick.commit.uri, pick.commit),
|
new GitUri(pick.commit.uri, pick.commit),
|
||||||
{
|
{
|
||||||
commit: pick.commit,
|
commit: pick.commit,
|
||||||
fileLog: args.log,
|
fileLog: args.log,
|
||||||
sha: pick.commit.sha,
|
sha: pick.commit.sha,
|
||||||
goBackCommand: currentCommand
|
goBackCommand: currentCommand
|
||||||
} as ShowQuickCommitFileDetailsCommandArgs);
|
} as ShowQuickCommitFileDetailsCommandArgs);
|
||||||
}
|
}
|
||||||
catch (ex) {
|
catch (ex) {
|
||||||
Logger.error(ex, 'ShowQuickFileHistoryCommand');
|
Logger.error(ex, 'ShowQuickFileHistoryCommand');
|
||||||
return window.showErrorMessage(`Unable to show file history. See output channel for more details`);
|
return window.showErrorMessage(`Unable to show file history. See output channel for more details`);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
progressCancellation.dispose();
|
progressCancellation.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@ import { AnnotationController } from './annotations/annotationController';
|
|||||||
import { CloseUnchangedFilesCommand, OpenChangedFilesCommand } from './commands';
|
import { CloseUnchangedFilesCommand, OpenChangedFilesCommand } from './commands';
|
||||||
import { OpenBranchInRemoteCommand, OpenCommitInRemoteCommand, OpenFileInRemoteCommand, OpenInRemoteCommand, OpenRepoInRemoteCommand } from './commands';
|
import { OpenBranchInRemoteCommand, OpenCommitInRemoteCommand, OpenFileInRemoteCommand, OpenInRemoteCommand, OpenRepoInRemoteCommand } from './commands';
|
||||||
import { CopyMessageToClipboardCommand, CopyShaToClipboardCommand } from './commands';
|
import { CopyMessageToClipboardCommand, CopyShaToClipboardCommand } from './commands';
|
||||||
import { DiffDirectoryCommand, DiffLineWithPreviousCommand, DiffLineWithWorkingCommand, DiffWithBranchCommand, DiffWithNextCommand, DiffWithPreviousCommand, DiffWithWorkingCommand} from './commands';
|
import { DiffDirectoryCommand, DiffLineWithPreviousCommand, DiffLineWithWorkingCommand, DiffWithBranchCommand, DiffWithNextCommand, DiffWithPreviousCommand, DiffWithRevisionCommand, DiffWithWorkingCommand} from './commands';
|
||||||
import { ResetSuppressedWarningsCommand } from './commands';
|
import { ResetSuppressedWarningsCommand } from './commands';
|
||||||
import { ShowFileBlameCommand, ShowLineBlameCommand, ToggleFileBlameCommand, ToggleFileRecentChangesCommand, ToggleLineBlameCommand } from './commands';
|
import { ShowFileBlameCommand, ShowLineBlameCommand, ToggleFileBlameCommand, ToggleFileRecentChangesCommand, ToggleLineBlameCommand } from './commands';
|
||||||
import { ShowBlameHistoryCommand, ShowFileHistoryCommand } from './commands';
|
import { ShowBlameHistoryCommand, ShowFileHistoryCommand } from './commands';
|
||||||
@@ -97,6 +97,7 @@ export async function activate(context: ExtensionContext) {
|
|||||||
context.subscriptions.push(new DiffWithBranchCommand(git));
|
context.subscriptions.push(new DiffWithBranchCommand(git));
|
||||||
context.subscriptions.push(new DiffWithNextCommand(git));
|
context.subscriptions.push(new DiffWithNextCommand(git));
|
||||||
context.subscriptions.push(new DiffWithPreviousCommand(git));
|
context.subscriptions.push(new DiffWithPreviousCommand(git));
|
||||||
|
context.subscriptions.push(new DiffWithRevisionCommand(git));
|
||||||
context.subscriptions.push(new DiffWithWorkingCommand(git));
|
context.subscriptions.push(new DiffWithWorkingCommand(git));
|
||||||
context.subscriptions.push(new OpenBranchInRemoteCommand(git));
|
context.subscriptions.push(new OpenBranchInRemoteCommand(git));
|
||||||
context.subscriptions.push(new OpenCommitInRemoteCommand(git));
|
context.subscriptions.push(new OpenCommitInRemoteCommand(git));
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ export class FileHistoryQuickPick {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static async show(git: GitService, log: GitLog, uri: GitUri, progressCancellation: CancellationTokenSource, goBackCommand?: CommandQuickPickItem, nextPageCommand?: CommandQuickPickItem): Promise<CommitQuickPickItem | CommandQuickPickItem | undefined> {
|
static async show(git: GitService, log: GitLog, uri: GitUri, progressCancellation: CancellationTokenSource, options: { goBackCommand?: CommandQuickPickItem, nextPageCommand?: CommandQuickPickItem, pickerOnly?: boolean } = {}): Promise<CommitQuickPickItem | CommandQuickPickItem | undefined> {
|
||||||
|
options = { ...{ pickerOnly: false }, ...options };
|
||||||
|
|
||||||
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)[];
|
||||||
|
|
||||||
let previousPageCommand: CommandQuickPickItem | undefined = undefined;
|
let previousPageCommand: CommandQuickPickItem | undefined = undefined;
|
||||||
@@ -36,7 +38,7 @@ export class FileHistoryQuickPick {
|
|||||||
Uri.file(uri.fsPath),
|
Uri.file(uri.fsPath),
|
||||||
{
|
{
|
||||||
maxCount: 0,
|
maxCount: 0,
|
||||||
goBackCommand
|
goBackCommand: options.goBackCommand
|
||||||
} as ShowQuickFileHistoryCommandArgs
|
} as ShowQuickFileHistoryCommandArgs
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
@@ -59,7 +61,7 @@ export class FileHistoryQuickPick {
|
|||||||
log: log,
|
log: log,
|
||||||
maxCount: log.maxCount,
|
maxCount: log.maxCount,
|
||||||
range: log.range,
|
range: log.range,
|
||||||
goBackCommand
|
goBackCommand: options.goBackCommand
|
||||||
} as ShowQuickFileHistoryCommandArgs
|
} as ShowQuickFileHistoryCommandArgs
|
||||||
])
|
])
|
||||||
} as ShowQuickFileHistoryCommandArgs
|
} as ShowQuickFileHistoryCommandArgs
|
||||||
@@ -67,9 +69,9 @@ export class FileHistoryQuickPick {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextPageCommand) {
|
if (options.nextPageCommand) {
|
||||||
index++;
|
index++;
|
||||||
items.splice(0, 0, nextPageCommand);
|
items.splice(0, 0, options.nextPageCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (log.truncated) {
|
if (log.truncated) {
|
||||||
@@ -80,8 +82,8 @@ export class FileHistoryQuickPick {
|
|||||||
uri,
|
uri,
|
||||||
{
|
{
|
||||||
maxCount: log.maxCount,
|
maxCount: log.maxCount,
|
||||||
goBackCommand,
|
goBackCommand: options.goBackCommand,
|
||||||
nextPageCommand
|
nextPageCommand: options.nextPageCommand
|
||||||
} as ShowQuickFileHistoryCommandArgs
|
} as ShowQuickFileHistoryCommandArgs
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -94,7 +96,7 @@ export class FileHistoryQuickPick {
|
|||||||
new GitUri(uri, last),
|
new GitUri(uri, last),
|
||||||
{
|
{
|
||||||
maxCount: log.maxCount,
|
maxCount: log.maxCount,
|
||||||
goBackCommand,
|
goBackCommand: options.goBackCommand,
|
||||||
nextPageCommand: npc
|
nextPageCommand: npc
|
||||||
} as ShowQuickFileHistoryCommandArgs
|
} as ShowQuickFileHistoryCommandArgs
|
||||||
]);
|
]);
|
||||||
@@ -105,54 +107,56 @@ export class FileHistoryQuickPick {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const branch = await git.getBranch(uri.repoPath!);
|
if (!options.pickerOnly) {
|
||||||
|
const branch = await git.getBranch(uri.repoPath!);
|
||||||
|
|
||||||
const currentCommand = new CommandQuickPickItem({
|
const currentCommand = new CommandQuickPickItem({
|
||||||
label: `go back ${GlyphChars.ArrowBack}`,
|
label: `go back ${GlyphChars.ArrowBack}`,
|
||||||
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} to history of ${GlyphChars.Space}$(file-text) ${path.basename(uri.fsPath)}${uri.sha ? ` from ${GlyphChars.Space}$(git-commit) ${uri.shortSha}` : ''}`
|
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} to history of ${GlyphChars.Space}$(file-text) ${path.basename(uri.fsPath)}${uri.sha ? ` from ${GlyphChars.Space}$(git-commit) ${uri.shortSha}` : ''}`
|
||||||
}, Commands.ShowQuickFileHistory, [
|
}, Commands.ShowQuickFileHistory, [
|
||||||
uri,
|
uri,
|
||||||
{
|
|
||||||
log,
|
|
||||||
maxCount: log.maxCount,
|
|
||||||
range: log.range
|
|
||||||
} as ShowQuickFileHistoryCommandArgs
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Only show the full repo option if we are the root
|
|
||||||
if (goBackCommand === undefined) {
|
|
||||||
items.splice(index++, 0, new CommandQuickPickItem({
|
|
||||||
label: `$(history) Show Branch History`,
|
|
||||||
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} shows ${GlyphChars.Space}$(git-branch) ${branch!.name} history`
|
|
||||||
}, Commands.ShowQuickCurrentBranchHistory,
|
|
||||||
[
|
|
||||||
undefined,
|
|
||||||
{
|
{
|
||||||
goBackCommand: currentCommand
|
log,
|
||||||
} as ShowQuickCurrentBranchHistoryCommandArgs
|
maxCount: log.maxCount,
|
||||||
]));
|
range: log.range
|
||||||
}
|
} as ShowQuickFileHistoryCommandArgs
|
||||||
|
]);
|
||||||
|
|
||||||
const remotes = Arrays.uniqueBy(await git.getRemotes(uri.repoPath!), _ => _.url, _ => !!_.provider);
|
// Only show the full repo option if we are the root
|
||||||
if (remotes.length) {
|
if (options.goBackCommand === undefined) {
|
||||||
items.splice(index++, 0, new OpenRemotesCommandQuickPickItem(remotes, {
|
items.splice(index++, 0, new CommandQuickPickItem({
|
||||||
type: 'file',
|
label: `$(history) Show Branch History`,
|
||||||
branch: branch!.name,
|
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} shows ${GlyphChars.Space}$(git-branch) ${branch!.name} history`
|
||||||
fileName: uri.getRelativePath(),
|
}, Commands.ShowQuickCurrentBranchHistory,
|
||||||
sha: uri.sha
|
[
|
||||||
} as RemoteResource, currentCommand));
|
undefined,
|
||||||
}
|
{
|
||||||
|
goBackCommand: currentCommand
|
||||||
|
} as ShowQuickCurrentBranchHistoryCommandArgs
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
if (goBackCommand) {
|
const remotes = Arrays.uniqueBy(await git.getRemotes(uri.repoPath!), _ => _.url, _ => !!_.provider);
|
||||||
items.splice(0, 0, goBackCommand);
|
if (remotes.length) {
|
||||||
|
items.splice(index++, 0, new OpenRemotesCommandQuickPickItem(remotes, {
|
||||||
|
type: 'file',
|
||||||
|
branch: branch!.name,
|
||||||
|
fileName: uri.getRelativePath(),
|
||||||
|
sha: uri.sha
|
||||||
|
} as RemoteResource, currentCommand));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.goBackCommand) {
|
||||||
|
items.splice(0, 0, options.goBackCommand);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (progressCancellation.token.isCancellationRequested) return undefined;
|
if (progressCancellation.token.isCancellationRequested) return undefined;
|
||||||
|
|
||||||
const scope = await Keyboard.instance.beginScope({
|
const scope = await Keyboard.instance.beginScope({
|
||||||
left: goBackCommand,
|
left: options.goBackCommand,
|
||||||
',': previousPageCommand,
|
',': previousPageCommand,
|
||||||
'.': nextPageCommand
|
'.': options.nextPageCommand
|
||||||
});
|
});
|
||||||
|
|
||||||
const commit = Iterables.first(log.commits.values());
|
const commit = Iterables.first(log.commits.values());
|
||||||
|
|||||||
Reference in New Issue
Block a user