Spits branch and status nodes into separate files

Removes status node for now
This commit is contained in:
Eric Amodio
2017-06-25 23:29:54 -04:00
parent bc21272409
commit 7fbee675f0
5 changed files with 100 additions and 79 deletions

View File

@@ -0,0 +1,29 @@
'use strict';
import { Iterables } from '../system';
import { ExtensionContext, TreeItem, TreeItemCollapsibleState } from 'vscode';
import { CommitNode } from './commitNode';
import { GlyphChars } from '../constants';
import { ExplorerNode, ResourceType } from './explorerNode';
import { GitBranch, GitService, GitUri } from '../gitService';
export class BranchHistoryNode extends ExplorerNode {
readonly resourceType: ResourceType = 'branch-history';
constructor(public branch: GitBranch, uri: GitUri, context: ExtensionContext, git: GitService) {
super(uri, context, git);
}
async getChildren(): Promise<CommitNode[]> {
const log = await this.git.getLogForRepo(this.uri.repoPath!, this.branch.name);
if (log === undefined) return [];
return [...Iterables.map(log.commits.values(), c => new CommitNode(c, this.uri, this.context, this.git))];
}
getTreeItem(): TreeItem {
const item = new TreeItem(`${this.branch.name}${this.branch.current ? ` ${GlyphChars.Dash} current` : ''}`, TreeItemCollapsibleState.Collapsed);
item.contextValue = this.resourceType;
return item;
}
}