Преглед изворни кода

Closes #502 - Adds show commit in results command

Adds show file history in results command
main
Eric Amodio пре 6 година
родитељ
комит
879c498f64
4 измењених фајлова са 89 додато и 16 уклоњено
  1. +43
    -10
      package.json
  2. +2
    -0
      src/commands/common.ts
  3. +14
    -1
      src/commands/showQuickCommitDetails.ts
  4. +30
    -5
      src/commands/showQuickFileHistory.ts

+ 43
- 10
package.json Прегледај датотеку

@ -1697,6 +1697,16 @@
"category": "GitLens"
},
{
"command": "gitlens.showCommitInResults",
"title": "Show Commit in Results",
"category": "GitLens"
},
{
"command": "gitlens.showFileHistoryInResults",
"title": "Show File History in Results",
"category": "GitLens"
},
{
"command": "gitlens.showQuickCommitDetails",
"title": "Show Commit Details",
"category": "GitLens"
@ -2407,6 +2417,14 @@
"when": "gitlens:enabled"
},
{
"command": "gitlens.showCommitInResults",
"when": "gitlens:activeFileStatus =~ /blameable/"
},
{
"command": "gitlens.showFileHistoryInResults",
"when": "gitlens:activeFileStatus =~ /tracked/"
},
{
"command": "gitlens.showQuickCommitDetails",
"when": "gitlens:activeFileStatus =~ /blameable/"
},
@ -3285,6 +3303,11 @@
"group": "5_gitlens_1@1"
},
{
"command": "gitlens.showCommitInResults",
"when": "viewItem =~ /gitlens:commit\\b/",
"group": "5_gitlens_1@2"
},
{
"command": "gitlens.explorers.terminalCherryPickCommit",
"when": "viewItem == gitlens:commit",
"group": "8_gitlens@1"
@ -3395,16 +3418,6 @@
"group": "5_gitlens@3"
},
{
"command": "gitlens.showQuickFileHistory",
"when": "viewItem =~ /gitlens:file\\b/",
"group": "8_gitlens@1"
},
{
"command": "gitlens.showQuickCommitDetails",
"when": "viewItem =~ /gitlens:file\\b(?!(:stash|:status))/",
"group": "8_gitlens@2"
},
{
"command": "gitlens.explorers.applyChanges",
"when": "viewItem =~ /gitlens:file:(commit|results)\\b/",
"group": "5_gitlens_1@1"
@ -3415,6 +3428,26 @@
"group": "1_gitlens@1"
},
{
"command": "gitlens.showQuickCommitDetails",
"when": "viewItem =~ /gitlens:file\\b(?!(:stash|:status))/",
"group": "5_gitlens_2@2"
},
{
"command": "gitlens.showCommitInResults",
"when": "viewItem =~ /gitlens:file\\b(?!(:stash|:status))/",
"group": "5_gitlens_2@3"
},
{
"command": "gitlens.showQuickFileHistory",
"when": "viewItem =~ /gitlens:file\\b/",
"group": "8_gitlens@1"
},
{
"command": "gitlens.showFileHistoryInResults",
"when": "viewItem =~ /gitlens:file\\b/",
"group": "8_gitlens@2"
},
{
"command": "gitlens.openBranchesInRemote",
"when": "viewItem == gitlens:remote",
"group": "1_gitlens@1"

+ 2
- 0
src/commands/common.ts Прегледај датотеку

@ -54,8 +54,10 @@ export enum Commands {
OpenRepoInRemote = 'gitlens.openRepoInRemote',
OpenWorkingFile = 'gitlens.openWorkingFile',
ResetSuppressedWarnings = 'gitlens.resetSuppressedWarnings',
ShowCommitInResults = 'gitlens.showCommitInResults',
ShowCommitSearch = 'gitlens.showCommitSearch',
ShowFileHistoryExplorer = 'gitlens.showFileHistoryExplorer',
ShowFileHistoryInResults = 'gitlens.showFileHistoryInResults',
ShowLineHistoryExplorer = 'gitlens.showLineHistoryExplorer',
ShowLastQuickPick = 'gitlens.showLastQuickPick',
ShowQuickBranchHistory = 'gitlens.showQuickBranchHistory',

+ 14
- 1
src/commands/showQuickCommitDetails.ts Прегледај датотеку

@ -21,6 +21,7 @@ export interface ShowQuickCommitDetailsCommandArgs {
sha?: string;
commit?: GitCommit | GitLogCommit;
repoLog?: GitLog;
showInResults?: boolean;
goBackCommand?: CommandQuickPickItem;
}
@ -37,10 +38,15 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand {
}
constructor() {
super([Commands.ShowQuickCommitDetails, Commands.ShowQuickRevisionDetails]);
super([Commands.ShowCommitInResults, Commands.ShowQuickCommitDetails, Commands.ShowQuickRevisionDetails]);
}
protected async preExecute(context: CommandContext, args: ShowQuickCommitDetailsCommandArgs = {}): Promise<any> {
if (context.command === Commands.ShowCommitInResults) {
args = { ...args };
args.showInResults = true;
}
if (context.command === Commands.ShowQuickRevisionDetails && context.editor !== undefined) {
args = { ...args };
@ -56,6 +62,7 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand {
args.commit = context.node.commit;
}
}
return this.execute(context.editor, context.uri, args);
}
@ -126,6 +133,12 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand {
args.commit.workingFileName = workingFileName;
}
if (args.showInResults) {
void (await Container.resultsExplorer.addCommit(args.commit as GitLogCommit));
return undefined;
}
if (args.goBackCommand === undefined) {
const branch = await Container.git.getBranch(args.commit.repoPath);
if (branch !== undefined) {

+ 30
- 5
src/commands/showQuickFileHistory.ts Прегледај датотеку

@ -13,7 +13,7 @@ import {
ShowCommitsInResultsQuickPickItem
} from '../quickpicks';
import { Iterables, Strings } from '../system';
import { ActiveEditorCachedCommand, Commands, getCommandUri } from './common';
import { ActiveEditorCachedCommand, CommandContext, Commands, getCommandUri } from './common';
import { ShowQuickCommitFileDetailsCommandArgs } from './showQuickCommitFileDetails';
export interface ShowQuickFileHistoryCommandArgs {
@ -21,6 +21,7 @@ export interface ShowQuickFileHistoryCommandArgs {
log?: GitLog;
maxCount?: number;
range?: Range;
showInResults?: boolean;
goBackCommand?: CommandQuickPickItem;
nextPageCommand?: CommandQuickPickItem;
@ -28,7 +29,16 @@ export interface ShowQuickFileHistoryCommandArgs {
export class ShowQuickFileHistoryCommand extends ActiveEditorCachedCommand {
constructor() {
super(Commands.ShowQuickFileHistory);
super([Commands.ShowFileHistoryInResults, Commands.ShowQuickFileHistory]);
}
protected async preExecute(context: CommandContext, args: ShowQuickFileHistoryCommandArgs = {}): Promise<any> {
if (context.command === Commands.ShowFileHistoryInResults) {
args = { ...args };
args.showInResults = true;
}
return this.execute(context.editor, context.uri, args);
}
async execute(editor?: TextEditor, uri?: Uri, args: ShowQuickFileHistoryCommandArgs = {}) {
@ -43,7 +53,11 @@ export class ShowQuickFileHistoryCommand extends ActiveEditorCachedCommand {
suffix: args.branchOrTag ? ` (${args.branchOrTag.name})` : undefined
})}${gitUri.sha ? ` ${Strings.pad(GlyphChars.Dot, 1, 1)} ${gitUri.shortSha}` : ''}`;
const progressCancellation = FileHistoryQuickPick.showProgress(placeHolder);
let progressCancellation;
if (!args.showInResults) {
progressCancellation = FileHistoryQuickPick.showProgress(placeHolder);
}
try {
if (args.log === undefined) {
args.log = await Container.git.getLogForFile(gitUri.repoPath, gitUri.fsPath, {
@ -59,7 +73,18 @@ export class ShowQuickFileHistoryCommand extends ActiveEditorCachedCommand {
}
}
if (progressCancellation.token.isCancellationRequested) return undefined;
if (progressCancellation !== undefined && progressCancellation.token.isCancellationRequested) {
return undefined;
}
if (args.showInResults) {
void (await Container.resultsExplorer.addSearchResults(gitUri.repoPath!, args.log, {
label: placeHolder,
resultsType: { singular: 'commit', plural: 'commits' }
}));
return undefined;
}
let previousPageCommand: CommandQuickPickItem | undefined = undefined;
@ -166,7 +191,7 @@ export class ShowQuickFileHistoryCommand extends ActiveEditorCachedCommand {
return Messages.showGenericErrorMessage('Unable to show file history');
}
finally {
progressCancellation.cancel();
progressCancellation && progressCancellation.cancel();
}
}
}

Loading…
Откажи
Сачувај