Browse Source

Adds Switch to Another Branch command

main
Eric Amodio 4 years ago
parent
commit
75b93f87c0
2 changed files with 39 additions and 6 deletions
  1. +33
    -5
      package.json
  2. +6
    -1
      src/views/viewCommands.ts

+ 33
- 5
package.json View File

@ -2991,6 +2991,15 @@
} }
}, },
{ {
"command": "gitlens.views.switchToAnotherBranch",
"title": "Switch to Another Branch",
"category": "GitLens",
"icon": {
"dark": "images/dark/icon-checkout.svg",
"light": "images/light/icon-checkout.svg"
}
},
{
"command": "gitlens.views.switchToBranch", "command": "gitlens.views.switchToBranch",
"title": "Switch to Branch", "title": "Switch to Branch",
"category": "GitLens", "category": "GitLens",
@ -4372,6 +4381,10 @@
"when": "false" "when": "false"
}, },
{ {
"command": "gitlens.views.switchToAnotherBranch",
"when": "false"
},
{
"command": "gitlens.views.switchToBranch", "command": "gitlens.views.switchToBranch",
"when": "false" "when": "false"
}, },
@ -5393,19 +5406,24 @@
"group": "navigation@12" "group": "navigation@12"
}, },
{ {
"command": "gitlens.views.switchToAnotherBranch",
"when": "!gitlens:readonly && view =~ /^gitlens\\.views\\.commits/",
"group": "navigation@13"
},
{
"command": "gitlens.views.repositories.setFilesLayoutToList", "command": "gitlens.views.repositories.setFilesLayoutToList",
"when": "view =~ /^gitlens\\.views\\.repositories:/ && config.gitlens.views.repositories.files.layout == auto", "when": "view =~ /^gitlens\\.views\\.repositories:/ && config.gitlens.views.repositories.files.layout == auto",
"group": "navigation@13"
"group": "navigation@14"
}, },
{ {
"command": "gitlens.views.repositories.setFilesLayoutToTree", "command": "gitlens.views.repositories.setFilesLayoutToTree",
"when": "view =~ /^gitlens\\.views\\.repositories:/ && config.gitlens.views.repositories.files.layout == list", "when": "view =~ /^gitlens\\.views\\.repositories:/ && config.gitlens.views.repositories.files.layout == list",
"group": "navigation@13"
"group": "navigation@14"
}, },
{ {
"command": "gitlens.views.repositories.setFilesLayoutToAuto", "command": "gitlens.views.repositories.setFilesLayoutToAuto",
"when": "view =~ /^gitlens\\.views\\.repositories:/ && config.gitlens.views.repositories.files.layout == tree", "when": "view =~ /^gitlens\\.views\\.repositories:/ && config.gitlens.views.repositories.files.layout == tree",
"group": "navigation@13"
"group": "navigation@14"
}, },
{ {
"command": "gitlens.views.repositories.refresh", "command": "gitlens.views.repositories.refresh",
@ -5911,8 +5929,13 @@
"group": "inline@9" "group": "inline@9"
}, },
{ {
"command": "gitlens.views.switchToAnotherBranch",
"when": "!gitlens:readonly && viewItem =~ /gitlens:branch\\b(?=.*?\\b\\+current\\b)/",
"group": "inline@10"
},
{
"command": "gitlens.views.switchToBranch", "command": "gitlens.views.switchToBranch",
"when": "!gitlens:readonly && viewItem =~ /gitlens:branch\\b/",
"when": "!gitlens:readonly && viewItem =~ /gitlens:branch\\b(?!.*?\\b\\+current\\b)/",
"group": "inline@10" "group": "inline@10"
}, },
{ {
@ -5942,8 +5965,13 @@
"group": "inline@99" "group": "inline@99"
}, },
{ {
"command": "gitlens.views.switchToAnotherBranch",
"when": "!gitlens:readonly && viewItem =~ /gitlens:branch\\b(?=.*?\\b\\+current\\b)/",
"group": "1_gitlens_actions@1"
},
{
"command": "gitlens.views.switchToBranch", "command": "gitlens.views.switchToBranch",
"when": "!gitlens:readonly && viewItem =~ /gitlens:branch\\b/",
"when": "!gitlens:readonly && viewItem =~ /gitlens:branch\\b(?!.*?\\b\\+current\\b)/",
"group": "1_gitlens_actions@1" "group": "1_gitlens_actions@1"
}, },
{ {

+ 6
- 1
src/views/viewCommands.ts View File

@ -131,6 +131,7 @@ export class ViewCommands {
commands.registerCommand('gitlens.views.highlightRevisionChanges', this.highlightRevisionChanges, this); commands.registerCommand('gitlens.views.highlightRevisionChanges', this.highlightRevisionChanges, this);
commands.registerCommand('gitlens.views.restore', this.restore, this); commands.registerCommand('gitlens.views.restore', this.restore, this);
commands.registerCommand('gitlens.views.switchToBranch', this.switch, this); commands.registerCommand('gitlens.views.switchToBranch', this.switch, this);
commands.registerCommand('gitlens.views.switchToAnotherBranch', this.switch, this);
commands.registerCommand('gitlens.views.switchToCommit', this.switch, this); commands.registerCommand('gitlens.views.switchToCommit', this.switch, this);
commands.registerCommand('gitlens.views.switchToTag', this.switch, this); commands.registerCommand('gitlens.views.switchToTag', this.switch, this);
commands.registerCommand('gitlens.views.addRemote', this.addRemote, this); commands.registerCommand('gitlens.views.addRemote', this.addRemote, this);
@ -477,7 +478,11 @@ export class ViewCommands {
} }
@debug() @debug()
private switch(node: ViewRefNode) {
private switch(node?: ViewRefNode) {
if (node == null) {
return GitActions.switchTo(Container.git.getHighlanderRepoPath());
}
if (!(node instanceof ViewRefNode)) return Promise.resolve(); if (!(node instanceof ViewRefNode)) return Promise.resolve();
return GitActions.switchTo( return GitActions.switchTo(

Loading…
Cancel
Save