Переглянути джерело

Adds reveal commit in repos view command

main
Eric Amodio 5 роки тому
джерело
коміт
74390df50f
3 змінених файлів з 44 додано та 13 видалено
  1. +21
    -2
      package.json
  2. +1
    -0
      src/commands/common.ts
  3. +22
    -11
      src/commands/showQuickCommitDetails.ts

+ 21
- 2
package.json Переглянути файл

@ -2227,6 +2227,11 @@
"category": "GitLens"
},
{
"command": "gitlens.revealCommitInView",
"title": "Reveal Commit in Repositories View",
"category": "GitLens"
},
{
"command": "gitlens.showCommitInView",
"title": "Show Commit in Search Commits View",
"category": "GitLens"
@ -3409,6 +3414,10 @@
"when": "gitlens:enabled"
},
{
"command": "gitlens.revealCommitInView",
"when": "gitlens:activeFileStatus =~ /blameable/"
},
{
"command": "gitlens.showCommitInView",
"when": "gitlens:activeFileStatus =~ /blameable/"
},
@ -4716,11 +4725,16 @@
"group": "2_gitlens_quickopen_@2"
},
{
"command": "gitlens.showCommitInView",
"command": "gitlens.revealCommitInView",
"when": "viewItem =~ /gitlens:commit\\b/",
"group": "3_gitlens_explore@1"
},
{
"command": "gitlens.showCommitInView",
"when": "viewItem =~ /gitlens:commit\\b/",
"group": "3_gitlens_explore@2"
},
{
"command": "gitlens.openCommitInRemote",
"when": "viewItem =~ /gitlens:commit\\b/ && gitlens:hasRemotes",
"group": "5_gitlens_open@1"
@ -4830,11 +4844,16 @@
"group": "3_gitlens_explore@4"
},
{
"command": "gitlens.showCommitInView",
"command": "gitlens.revealCommitInView",
"when": "viewItem =~ /gitlens:file\\b(?!(:stash|:status))/",
"group": "3_gitlens_explore@3"
},
{
"command": "gitlens.showCommitInView",
"when": "viewItem =~ /gitlens:file\\b(?!(:stash|:status))/",
"group": "3_gitlens_explore@4"
},
{
"command": "gitlens.openFileInRemote",
"when": "viewItem =~ /gitlens:file\\b/ && gitlens:hasRemotes",
"group": "5_gitlens_open@1"

+ 1
- 0
src/commands/common.ts Переглянути файл

@ -71,6 +71,7 @@ export enum Commands {
PushRepositories = 'gitlens.pushRepositories',
GitCommands = 'gitlens.gitCommands',
ResetSuppressedWarnings = 'gitlens.resetSuppressedWarnings',
RevealCommitInView = 'gitlens.revealCommitInView',
ShowCommitInView = 'gitlens.showCommitInView',
SearchCommits = 'gitlens.showCommitSearch',
SearchCommitsInView = 'gitlens.views.search.searchCommits',

+ 22
- 11
src/commands/showQuickCommitDetails.ts Переглянути файл

@ -20,7 +20,7 @@ export interface ShowQuickCommitDetailsCommandArgs {
sha?: string;
commit?: GitCommit | GitLogCommit;
repoLog?: GitLog;
showInView?: boolean;
showInView?: 'reveal' | 'show';
goBackCommand?: CommandQuickPickItem;
}
@ -38,13 +38,16 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand {
}
constructor() {
super([Commands.ShowCommitInView, Commands.ShowQuickCommitDetails]);
super([Commands.RevealCommitInView, Commands.ShowCommitInView, Commands.ShowQuickCommitDetails]);
}
protected preExecute(context: CommandContext, args?: ShowQuickCommitDetailsCommandArgs) {
if (context.command === Commands.ShowCommitInView) {
if (context.command === Commands.RevealCommitInView) {
args = { ...args };
args.showInView = true;
args.showInView = 'reveal';
} else if (context.command === Commands.ShowCommitInView) {
args = { ...args };
args.showInView = 'show';
}
if (context.type === 'viewItem') {
@ -120,13 +123,21 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand {
}
if (args.showInView) {
void (await Container.searchView.search(
repoPath!,
{ pattern: SearchPattern.fromCommit(args.commit) },
{
label: { label: `for commit id ${args.commit.shortSha}` }
}
));
if (args.showInView === 'reveal') {
void (await Container.repositoriesView.revealCommit(args.commit, {
select: true,
focus: true,
expand: true
}));
} else {
void (await Container.searchView.search(
repoPath!,
{ pattern: SearchPattern.fromCommit(args.commit) },
{
label: { label: `for commit id ${args.commit.shortSha}` }
}
));
}
return undefined;
}

Завантаження…
Відмінити
Зберегти