Adds new GitLens custom view

This commit is contained in:
Eric Amodio
2017-08-30 12:26:30 -04:00
parent ed58dc3b49
commit 9782a81e46
69 changed files with 983 additions and 644 deletions

View File

@@ -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;
}
}