소스 검색

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,
);
}

불러오는 중...
취소
저장