瀏覽代碼

Adds switch & create branch to Branches

main
Eric Amodio 3 年之前
父節點
當前提交
510bc2334c
共有 3 個文件被更改,包括 33 次插入10 次删除
  1. +23
    -3
      package.json
  2. +4
    -0
      src/views/nodes/branchesNode.ts
  3. +6
    -7
      src/views/viewCommands.ts

+ 23
- 3
package.json 查看文件

@ -6671,14 +6671,24 @@
],
"view/item/context": [
{
"command": "gitlens.views.switchToAnotherBranch",
"when": "!gitlens:readonly && viewItem =~ /gitlens:branches\\b/",
"group": "inline@10"
},
{
"command": "gitlens.views.createBranch",
"when": "!gitlens:readonly && viewItem =~ /gitlens:branches\\b/",
"group": "inline@11"
},
{
"command": "gitlens.views.repositories.setBranchesLayoutToList",
"when": "viewItem =~ /gitlens:branches\\b/ && config.gitlens.views.repositories.branches.layout == tree",
"group": "inline@1"
"group": "inline@50"
},
{
"command": "gitlens.views.repositories.setBranchesLayoutToTree",
"when": "viewItem =~ /gitlens:branches\\b/ && config.gitlens.views.repositories.branches.layout == list",
"group": "inline@1"
"group": "inline@50"
},
{
"command": "gitlens.openBranchesOnRemote",
@ -6687,9 +6697,19 @@
"alt": "gitlens.copyRemoteBranchesUrl"
},
{
"command": "gitlens.views.switchToAnotherBranch",
"when": "!gitlens:readonly && viewItem =~ /gitlens:branches\\b/",
"group": "1_gitlens_actions@1"
},
{
"command": "gitlens.views.createBranch",
"when": "!gitlens:readonly && viewItem =~ /gitlens:branches\\b/",
"group": "1_gitlens_actions@2"
},
{
"command": "gitlens.openBranchesOnRemote",
"when": "viewItem =~ /gitlens:branches\\b(?=.*?\\b\\+remotes\\b)/",
"group": "1_gitlens@1",
"group": "2_gitlens_quickopen@1",
"alt": "gitlens.copyRemoteBranchesUrl"
},
{

+ 4
- 0
src/views/nodes/branchesNode.ts 查看文件

@ -33,6 +33,10 @@ export class BranchesNode extends ViewNode {
return BranchesNode.getId(this.repo.path);
}
get repoPath(): string {
return this.repo.path;
}
async getChildren(): Promise<ViewNode[]> {
if (this._children == null) {
const branches = await this.repo.getBranches({

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

@ -18,6 +18,7 @@ import { Container } from '../container';
import { GitReference, GitRevision } from '../git/git';
import { GitUri } from '../git/gitUri';
import {
BranchesNode,
BranchNode,
BranchTrackingStatusNode,
CommitFileNode,
@ -258,10 +259,8 @@ export class ViewCommands {
}
@debug()
private createBranch(node?: ViewRefNode) {
if (node != null && !(node instanceof ViewRefNode)) return Promise.resolve();
return GitActions.Branch.create(node?.repoPath, node?.ref);
private createBranch(node?: ViewRefNode | BranchesNode) {
return GitActions.Branch.create(node?.repoPath, node instanceof ViewRefNode ? node?.ref : undefined);
}
@debug()
@ -562,16 +561,16 @@ export class ViewCommands {
}
@debug()
private switch(node?: ViewRefNode) {
private switch(node?: ViewRefNode | BranchesNode) {
if (node == null) {
return GitActions.switchTo(Container.git.getHighlanderRepoPath());
}
if (!(node instanceof ViewRefNode)) return Promise.resolve();
if (!(node instanceof ViewRefNode) && !(node instanceof BranchesNode)) return Promise.resolve();
return GitActions.switchTo(
node.repoPath,
node instanceof BranchNode && node.branch.current ? undefined : node.ref,
node instanceof BranchesNode || (node instanceof BranchNode && node.branch.current) ? undefined : node.ref,
);
}

Loading…
取消
儲存