Skip to content

Commit

Permalink
Do not parse invalid branch name as branch folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Yukaii committed Jan 30, 2018
1 parent 5a5c936 commit 360bf2e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/views/branchNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ export class BranchNode extends ExplorerRefNode {
}

get label(): string {
const branchName = this.branch.getName();
if (this.explorer.config.branches.layout === ExplorerBranchesLayout.List) {
return this.branch.getName();
return branchName;
} else {
return this.branch.getBasename();
return !!branchName.match(/\s/) ? branchName : this.branch.getBasename();
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/views/branchesNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ export class BranchesNode extends ExplorerNode {
return branchNodes;
}

const hierarchy = Arrays.makeHierarchical(branchNodes, n => n.branch.name.split('/'),
(...paths: string[]) => paths.join('/'), this.explorer.config.files.compact);
const hierarchy = Arrays.makeHierarchical(branchNodes,
n => !!n.branch.name.match(/\s/) ? [n.branch.name] : n.branch.name.split('/'),
(...paths: string[]) => paths.join('/'), this.explorer.config.files.compact);

const root = new BranchFolderNode(this.repo.path, '', undefined, hierarchy, this.explorer);
children = await root.getChildren() as (BranchFolderNode | BranchNode)[];
Expand Down
2 changes: 1 addition & 1 deletion src/views/remoteNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class RemoteNode extends ExplorerNode {

const hierarchy = Arrays.makeHierarchical(
branchNodes,
n => n.branch.name.split('/').slice(1), // remove remote name
n => !!n.branch.name.match(/\s/) ? [n.branch.name] : n.branch.name.split('/').slice(1), // remove remote name
(...paths: string[]) => paths.join('/'),
this.explorer.config.files.compact
);
Expand Down

0 comments on commit 360bf2e

Please sign in to comment.