Adds an experimental custom view (wip)

This commit is contained in:
Eric Amodio
2017-06-12 12:25:09 -04:00
parent 3081632815
commit c812a56eac
20 changed files with 1939 additions and 1401 deletions

54
src/views/commitNode.ts Normal file
View File

@@ -0,0 +1,54 @@
'use strict';
import { Iterables } from '../system';
import { Command, ExtensionContext, TreeItem, TreeItemCollapsibleState } from 'vscode';
import { CommitFileNode } from './commitFileNode';
import { ExplorerNode, ResourceType } from './explorerNode';
import { CommitFormatter, GitCommit, GitService, GitUri } from '../gitService';
export class CommitNode extends ExplorerNode {
readonly resourceType: ResourceType = 'commit';
command: Command;
constructor(public commit: GitCommit, uri: GitUri, context: ExtensionContext, git: GitService) {
super(uri, context, git);
// this.command = {
// title: 'Compare File with Previous',
// command: Commands.DiffWithPrevious,
// arguments: [
// Uri.file(commit.uri.fsPath),
// {
// commit: commit,
// showOptions: {
// preserveFocus: true,
// preview: true
// }
// } as DiffWithPreviousCommandArgs
// ]
// };
}
async getChildren(): Promise<ExplorerNode[]> {
const log = await this.git.getLogForRepo(this.commit.repoPath, this.commit.sha, 1);
if (log === undefined) return [];
const commit = Iterables.first(log.commits.values());
if (commit === undefined) return [];
return [...Iterables.map(commit.fileStatuses, s => new CommitFileNode(s, commit, this.uri, this.context, this.git))];
}
getTreeItem(): TreeItem {
const label = CommitFormatter.fromTemplate(this.git.config.explorer.commitFormat, this.commit, this.git.config.defaultDateFormat);
const item = new TreeItem(label, TreeItemCollapsibleState.Collapsed);
item.contextValue = this.resourceType;
item.iconPath = {
dark: this.context.asAbsolutePath('images/dark/icon-commit.svg'),
light: this.context.asAbsolutePath('images/light/icon-commit.svg')
};
item.command = this.command;
return item;
}
}