Skip to content

Commit

Permalink
Adds commands for git command palette commands
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Mar 28, 2021
1 parent 480e2f8 commit 31f0099
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 2 deletions.
76 changes: 76 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3350,6 +3350,46 @@
"title": "Git Command Palette",
"category": "GitLens"
},
{
"command": "gitlens.gitCommands.branch",
"title": "Git Branch...",
"category": "GitLens"
},
{
"command": "gitlens.gitCommands.cherryPick",
"title": "Git Cherry Pick...",
"category": "GitLens"
},
{
"command": "gitlens.gitCommands.merge",
"title": "Git Merge...",
"category": "GitLens"
},
{
"command": "gitlens.gitCommands.rebase",
"title": "Git Rebase...",
"category": "GitLens"
},
{
"command": "gitlens.gitCommands.reset",
"title": "Git Reset...",
"category": "GitLens"
},
{
"command": "gitlens.gitCommands.revert",
"title": "Git Revert...",
"category": "GitLens"
},
{
"command": "gitlens.gitCommands.switch",
"title": "Git Switch...",
"category": "GitLens"
},
{
"command": "gitlens.gitCommands.tag",
"title": "Git Tag...",
"category": "GitLens"
},
{
"command": "gitlens.switchMode",
"title": "Switch Mode",
Expand Down Expand Up @@ -5282,6 +5322,42 @@
"command": "gitlens.gitCommands",
"when": "!gitlens:disabled && !gitlens:readonly"
},
{
"command": "gitlens.gitCommands.branch",
"when": "!gitlens:disabled && !gitlens:readonly"
},
{
"command": "gitlens.gitCommands.cherryPick",
"when": "!gitlens:disabled && !gitlens:readonly"
},
{
"command": "gitlens.gitCommands.merge",
"when": "!gitlens:disabled && !gitlens:readonly"
},
{
"command": "gitlens.gitCommands.rebase",
"when": "!gitlens:disabled && !gitlens:readonly"
},
{
"command": "gitlens.gitCommands.reset",
"when": "!gitlens:disabled && !gitlens:readonly"
},
{
"command": "gitlens.gitCommands.revert",
"when": "!gitlens:disabled && !gitlens:readonly"
},
{
"command": "gitlens.gitCommands.show",
"when": "!gitlens:disabled && !gitlens:readonly"
},
{
"command": "gitlens.gitCommands.switch",
"when": "!gitlens:disabled && !gitlens:readonly"
},
{
"command": "gitlens.gitCommands.tag",
"when": "!gitlens:disabled && !gitlens:readonly"
},
{
"command": "gitlens.switchMode",
"when": "gitlens:enabled"
Expand Down
8 changes: 8 additions & 0 deletions src/commands/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ export enum Commands {
PullRepositories = 'gitlens.pullRepositories',
PushRepositories = 'gitlens.pushRepositories',
GitCommands = 'gitlens.gitCommands',
GitCommandsBranch = 'gitlens.gitCommands.branch',
GitCommandsCherryPick = 'gitlens.gitCommands.cherryPick',
GitCommandsMerge = 'gitlens.gitCommands.merge',
GitCommandsRebase = 'gitlens.gitCommands.rebase',
GitCommandsReset = 'gitlens.gitCommands.reset',
GitCommandsRevert = 'gitlens.gitCommands.revert',
GitCommandsSwitch = 'gitlens.gitCommands.switch',
GitCommandsTag = 'gitlens.gitCommands.tag',
QuickOpenFileHistory = 'gitlens.quickOpenFileHistory',
RefreshHover = 'gitlens.refreshHover',
ResetAvatarCache = 'gitlens.resetAvatarCache',
Expand Down
45 changes: 43 additions & 2 deletions src/commands/gitCommands.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
import { Disposable, InputBox, QuickInputButton, QuickInputButtons, QuickPick, QuickPickItem, window } from 'vscode';
import { command, Command, Commands } from './common';
import { command, Command, CommandContext, Commands } from './common';
import { configuration, GitCommandSorting } from '../configuration';
import { Usage, WorkspaceState } from '../constants';
import { Container } from '../container';
Expand Down Expand Up @@ -79,7 +79,48 @@ export class GitCommandsCommand extends Command {
private startedWith: 'menu' | 'command' = 'menu';

constructor() {
super(Commands.GitCommands);
super([
Commands.GitCommands,
Commands.GitCommandsBranch,
Commands.GitCommandsCherryPick,
Commands.GitCommandsMerge,
Commands.GitCommandsRebase,
Commands.GitCommandsReset,
Commands.GitCommandsRevert,
Commands.GitCommandsSwitch,
Commands.GitCommandsTag,
]);
}

protected preExecute(context: CommandContext, args?: GitCommandsCommandArgs) {
switch (context.command) {
case Commands.GitCommandsBranch:
args = { command: 'branch' };
break;
case Commands.GitCommandsCherryPick:
args = { command: 'cherry-pick' };
break;
case Commands.GitCommandsMerge:
args = { command: 'merge' };
break;
case Commands.GitCommandsRebase:
args = { command: 'rebase' };
break;
case Commands.GitCommandsReset:
args = { command: 'reset' };
break;
case Commands.GitCommandsRevert:
args = { command: 'revert' };
break;
case Commands.GitCommandsSwitch:
args = { command: 'switch' };
break;
case Commands.GitCommandsTag:
args = { command: 'tag' };
break;
}

return this.execute(args);
}

@log({ args: false, correlate: true, singleLine: true, timed: false })
Expand Down

0 comments on commit 31f0099

Please sign in to comment.