mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-17 17:25:51 -05:00
Adds new GitLens custom view
This commit is contained in:
@@ -7,22 +7,29 @@ import { GitService, GitUri } from '../gitService';
|
||||
|
||||
export class BranchesNode extends ExplorerNode {
|
||||
|
||||
readonly resourceType: ResourceType = 'branches';
|
||||
readonly resourceType: ResourceType = 'gitlens:branches';
|
||||
|
||||
constructor(uri: GitUri, protected readonly context: ExtensionContext, protected readonly git: GitService) {
|
||||
super(uri);
|
||||
}
|
||||
|
||||
async getChildren(): Promise<BranchHistoryNode[]> {
|
||||
async getChildren(): Promise<ExplorerNode[]> {
|
||||
const branches = await this.git.getBranches(this.uri.repoPath!);
|
||||
if (branches === undefined) return [];
|
||||
|
||||
return [...Iterables.filterMap(branches.sort(_ => _.current ? 0 : 1), b => b.remote ? undefined : new BranchHistoryNode(b, this.uri, this.context, this.git))];
|
||||
branches.sort((a, b) => (a.current ? -1 : 1) - (b.current ? -1 : 1) || a.name.localeCompare(b.name));
|
||||
return [...Iterables.filterMap(branches, b => b.remote ? undefined : new BranchHistoryNode(b, undefined, this.uri, this.git.config.gitExplorer.commitFormat, this.context, this.git))];
|
||||
}
|
||||
|
||||
getTreeItem(): TreeItem {
|
||||
const item = new TreeItem(`Branches`, TreeItemCollapsibleState.Collapsed);
|
||||
const item = new TreeItem(`Branches`, TreeItemCollapsibleState.Expanded);
|
||||
item.contextValue = this.resourceType;
|
||||
|
||||
item.iconPath = {
|
||||
dark: this.context.asAbsolutePath('images/dark/icon-branch.svg'),
|
||||
light: this.context.asAbsolutePath('images/light/icon-branch.svg')
|
||||
};
|
||||
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user