mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-14 10:03:15 -05:00
Adds an experimental custom view (wip)
This commit is contained in:
54
src/views/commitNode.ts
Normal file
54
src/views/commitNode.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user