浏览代码

Adds Switch to Another Branch command

main
Eric Amodio 4 年前
父节点
当前提交
75b93f87c0
共有 2 个文件被更改,包括 39 次插入6 次删除
  1. +33
    -5
      package.json
  2. +6
    -1
      src/views/viewCommands.ts

+ 33
- 5
package.json 查看文件

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

+ 6
- 1
src/views/viewCommands.ts 查看文件

@ -131,6 +131,7 @@ export class ViewCommands {
commands.registerCommand('gitlens.views.highlightRevisionChanges', this.highlightRevisionChanges, this);
commands.registerCommand('gitlens.views.restore', this.restore, 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.switchToTag', this.switch, this);
commands.registerCommand('gitlens.views.addRemote', this.addRemote, this);
@ -477,7 +478,11 @@ export class ViewCommands {
}
@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();
return GitActions.switchTo(

正在加载...
取消
保存