mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-16 10:58:34 -05:00
Adds Show Branch History command
Renames Show Repository History to Show Current Branch History Doesn't migrate data yet
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import { commands, Disposable, TextEditor, TextEditorEdit, Uri, window, workspace } from 'vscode';
|
||||
import { BuiltInCommands } from '../constants';
|
||||
|
||||
export type Commands = 'gitlens.closeUnchangedFiles' | 'gitlens.copyMessageToClipboard' | 'gitlens.copyShaToClipboard' | 'gitlens.diffDirectory' | 'gitlens.diffWithBranch' | 'gitlens.diffWithNext' | 'gitlens.diffWithPrevious' | 'gitlens.diffLineWithPrevious' | 'gitlens.diffWithWorking' | 'gitlens.diffLineWithWorking' | 'gitlens.openChangedFiles' | 'gitlens.showBlame' | 'gitlens.showBlameHistory' | 'gitlens.showFileHistory' | 'gitlens.showLastQuickPick' | 'gitlens.showQuickCommitDetails' | 'gitlens.showQuickCommitFileDetails' | 'gitlens.showQuickFileHistory' | 'gitlens.showQuickRepoHistory' | 'gitlens.showQuickRepoStatus' | 'gitlens.toggleBlame' | 'gitlens.toggleCodeLens';
|
||||
export type Commands = 'gitlens.closeUnchangedFiles' | 'gitlens.copyMessageToClipboard' | 'gitlens.copyShaToClipboard' | 'gitlens.diffDirectory' | 'gitlens.diffWithBranch' | 'gitlens.diffWithNext' | 'gitlens.diffWithPrevious' | 'gitlens.diffLineWithPrevious' | 'gitlens.diffWithWorking' | 'gitlens.diffLineWithWorking' | 'gitlens.openChangedFiles' | 'gitlens.showBlame' | 'gitlens.showBlameHistory' | 'gitlens.showFileHistory' | 'gitlens.showLastQuickPick' | 'gitlens.showQuickBranchHistory' | 'gitlens.showQuickCommitDetails' | 'gitlens.showQuickCommitFileDetails' | 'gitlens.showQuickFileHistory' | 'gitlens.showQuickRepoHistory' | 'gitlens.showQuickRepoStatus' | 'gitlens.toggleBlame' | 'gitlens.toggleCodeLens';
|
||||
export const Commands = {
|
||||
CloseUnchangedFiles: 'gitlens.closeUnchangedFiles' as Commands,
|
||||
CopyMessageToClipboard: 'gitlens.copyMessageToClipboard' as Commands,
|
||||
@@ -22,7 +22,8 @@ export const Commands = {
|
||||
ShowQuickCommitDetails: 'gitlens.showQuickCommitDetails' as Commands,
|
||||
ShowQuickCommitFileDetails: 'gitlens.showQuickCommitFileDetails' as Commands,
|
||||
ShowQuickFileHistory: 'gitlens.showQuickFileHistory' as Commands,
|
||||
ShowQuickRepoHistory: 'gitlens.showQuickRepoHistory' as Commands,
|
||||
ShowQuickBranchHistory: 'gitlens.showQuickBranchHistory' as Commands,
|
||||
ShowQuickCurrentBranchHistory: 'gitlens.showQuickRepoHistory' as Commands,
|
||||
ShowQuickRepoStatus: 'gitlens.showQuickRepoStatus' as Commands,
|
||||
ToggleBlame: 'gitlens.toggleBlame' as Commands,
|
||||
ToggleCodeLens: 'gitlens.toggleCodeLens' as Commands
|
||||
|
||||
@@ -3,12 +3,12 @@ import { commands, TextEditor, Uri, window } from 'vscode';
|
||||
import { ActiveEditorCachedCommand, Commands } from '../commands';
|
||||
import { GitService, GitUri, IGitLog } from '../gitService';
|
||||
import { Logger } from '../logger';
|
||||
import { CommandQuickPickItem, RepoHistoryQuickPick } from '../quickPicks';
|
||||
import { BranchesQuickPick, BranchHistoryQuickPick, CommandQuickPickItem } from '../quickPicks';
|
||||
|
||||
export class ShowQuickRepoHistoryCommand extends ActiveEditorCachedCommand {
|
||||
export class ShowQuickBranchHistoryCommand extends ActiveEditorCachedCommand {
|
||||
|
||||
constructor(private git: GitService, private repoPath: string) {
|
||||
super(Commands.ShowQuickRepoHistory);
|
||||
super(Commands.ShowQuickBranchHistory);
|
||||
}
|
||||
|
||||
async execute(editor: TextEditor, uri?: Uri, branch?: string, maxCount?: number, goBackCommand?: CommandQuickPickItem, log?: IGitLog, nextPageCommand?: CommandQuickPickItem) {
|
||||
@@ -22,23 +22,35 @@ export class ShowQuickRepoHistoryCommand extends ActiveEditorCachedCommand {
|
||||
maxCount = this.git.config.advanced.maxQuickHistory;
|
||||
}
|
||||
|
||||
branch = branch || (await this.git.getBranch(this.git.repoPath)).name;
|
||||
|
||||
const progressCancellation = RepoHistoryQuickPick.showProgress(branch);
|
||||
let progressCancellation = branch && BranchHistoryQuickPick.showProgress(branch);
|
||||
try {
|
||||
const repoPath = (gitUri && gitUri.repoPath) || await this.git.getRepoPathFromUri(uri, this.repoPath);
|
||||
if (!repoPath) return window.showWarningMessage(`Unable to show history`);
|
||||
if (!repoPath) return window.showWarningMessage(`Unable to show branch history`);
|
||||
|
||||
if (progressCancellation.token.isCancellationRequested) return undefined;
|
||||
if (!branch) {
|
||||
const branches = await this.git.getBranches(repoPath);
|
||||
|
||||
const pick = await BranchesQuickPick.show(branches, `pick a branch to show history`);
|
||||
if (!pick) return undefined;
|
||||
|
||||
if (pick instanceof CommandQuickPickItem) {
|
||||
return pick.execute();
|
||||
}
|
||||
|
||||
branch = pick.branch.name;
|
||||
if (!branch) return undefined;
|
||||
|
||||
progressCancellation = BranchHistoryQuickPick.showProgress(branch);
|
||||
}
|
||||
|
||||
if (!log) {
|
||||
log = await this.git.getLogForRepo(repoPath, (gitUri && gitUri.sha) || branch, maxCount);
|
||||
if (!log) return window.showWarningMessage(`Unable to show history`);
|
||||
if (!log) return window.showWarningMessage(`Unable to show branch history`);
|
||||
}
|
||||
|
||||
if (progressCancellation.token.isCancellationRequested) return undefined;
|
||||
|
||||
const pick = await RepoHistoryQuickPick.show(log, gitUri, branch, progressCancellation, goBackCommand, nextPageCommand);
|
||||
const pick = await BranchHistoryQuickPick.show(log, gitUri, branch, progressCancellation, goBackCommand, nextPageCommand);
|
||||
if (!pick) return undefined;
|
||||
|
||||
if (pick instanceof CommandQuickPickItem) {
|
||||
@@ -49,15 +61,15 @@ export class ShowQuickRepoHistoryCommand extends ActiveEditorCachedCommand {
|
||||
new CommandQuickPickItem({
|
||||
label: `go back \u21A9`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 to \u00a0$(git-branch) ${branch} history`
|
||||
}, Commands.ShowQuickRepoHistory, [uri, branch, maxCount, goBackCommand, log]),
|
||||
}, Commands.ShowQuickBranchHistory, [uri, branch, maxCount, goBackCommand, log]),
|
||||
log);
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.ShowQuickRepoHistoryCommand]', ex);
|
||||
return window.showErrorMessage(`Unable to show history. See output channel for more details`);
|
||||
Logger.error('[GitLens.ShowQuickBranchHistoryCommand]', ex);
|
||||
return window.showErrorMessage(`Unable to show branch history. See output channel for more details`);
|
||||
}
|
||||
finally {
|
||||
progressCancellation.dispose();
|
||||
progressCancellation && progressCancellation.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,7 +72,7 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand {
|
||||
goBackCommand = new CommandQuickPickItem({
|
||||
label: `go back \u21A9`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 to branch history`
|
||||
}, Commands.ShowQuickRepoHistory, [new GitUri(commit.uri, commit)]);
|
||||
}, Commands.ShowQuickCurrentBranchHistory, [new GitUri(commit.uri, commit)]);
|
||||
}
|
||||
|
||||
const pick = await CommitDetailsQuickPick.show(this.git, commit as GitLogCommit, uri, goBackCommand, repoLog);
|
||||
|
||||
29
src/commands/showQuickCurrentBranchHistory.ts
Normal file
29
src/commands/showQuickCurrentBranchHistory.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
import { commands, TextEditor, Uri, window } from 'vscode';
|
||||
import { ActiveEditorCachedCommand, Commands } from '../commands';
|
||||
import { GitService } from '../gitService';
|
||||
import { Logger } from '../logger';
|
||||
import { CommandQuickPickItem } from '../quickPicks';
|
||||
|
||||
export class ShowQuickCurrentBranchHistoryCommand extends ActiveEditorCachedCommand {
|
||||
|
||||
constructor(private git: GitService) {
|
||||
super(Commands.ShowQuickCurrentBranchHistory);
|
||||
}
|
||||
|
||||
async execute(editor: TextEditor, uri?: Uri, goBackCommand?: CommandQuickPickItem) {
|
||||
if (!(uri instanceof Uri)) {
|
||||
uri = editor && editor.document && editor.document.uri;
|
||||
}
|
||||
|
||||
try {
|
||||
const branch = (await this.git.getBranch(this.git.repoPath)).name;
|
||||
|
||||
return commands.executeCommand(Commands.ShowQuickBranchHistory, uri, branch, undefined, goBackCommand);
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.ShowQuickCurrentBranchHistoryCommand]', ex);
|
||||
return window.showErrorMessage(`Unable to show branch history. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ export class ShowQuickFileHistoryCommand extends ActiveEditorCachedCommand {
|
||||
uri = editor && editor.document && editor.document.uri;
|
||||
}
|
||||
|
||||
if (!uri) return commands.executeCommand(Commands.ShowQuickRepoHistory);
|
||||
if (!uri) return commands.executeCommand(Commands.ShowQuickCurrentBranchHistory);
|
||||
|
||||
const gitUri = await GitUri.fromUri(uri, this.git);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user