|
|
@ -4,7 +4,7 @@ import { Command, ExtensionContext, TreeItem, TreeItemCollapsibleState } from 'v |
|
|
|
import { Commands, DiffWithPreviousCommandArgs } from '../commands'; |
|
|
|
import { CommitFileNode } from './commitFileNode'; |
|
|
|
import { ExplorerNode, ResourceType } from './explorerNode'; |
|
|
|
import { CommitFormatter, getGitStatusIcon, GitLogCommit, GitService, GitUri } from '../gitService'; |
|
|
|
import { CommitFormatter, getGitStatusIcon, GitLogCommit, GitService, GitUri, ICommitFormatOptions } from '../gitService'; |
|
|
|
import * as path from 'path'; |
|
|
|
|
|
|
|
export class CommitNode extends ExplorerNode { |
|
|
@ -28,7 +28,11 @@ export class CommitNode extends ExplorerNode { |
|
|
|
} |
|
|
|
|
|
|
|
getTreeItem(): TreeItem { |
|
|
|
const item = new TreeItem(CommitFormatter.fromTemplate(this.template, this.commit, this.git.config.defaultDateFormat)); |
|
|
|
const item = new TreeItem(CommitFormatter.fromTemplate(this.template, this.commit, { |
|
|
|
truncateMessageAtNewLine: true, |
|
|
|
dataFormat: this.git.config.defaultDateFormat |
|
|
|
} as ICommitFormatOptions)); |
|
|
|
|
|
|
|
if (this.commit.type === 'file') { |
|
|
|
item.collapsibleState = TreeItemCollapsibleState.None; |
|
|
|
item.command = this.getCommand(); |
|
|
@ -55,17 +59,6 @@ export class CommitNode extends ExplorerNode { |
|
|
|
} |
|
|
|
|
|
|
|
getCommand(): Command | undefined { |
|
|
|
let allowMissingPrevious = false; |
|
|
|
let prefix = undefined; |
|
|
|
const status = this.commit.fileStatuses[0]; |
|
|
|
if (status.status === 'A') { |
|
|
|
allowMissingPrevious = true; |
|
|
|
prefix = 'added in '; |
|
|
|
} |
|
|
|
else if (status.status === 'D') { |
|
|
|
prefix = 'deleted in '; |
|
|
|
} |
|
|
|
|
|
|
|
return { |
|
|
|
title: 'Compare File with Previous Revision', |
|
|
|
command: Commands.DiffWithPrevious, |
|
|
@ -77,9 +70,7 @@ export class CommitNode extends ExplorerNode { |
|
|
|
showOptions: { |
|
|
|
preserveFocus: true, |
|
|
|
preview: true |
|
|
|
}, |
|
|
|
allowMissingPrevious: allowMissingPrevious, |
|
|
|
rightTitlePrefix: prefix |
|
|
|
} |
|
|
|
} as DiffWithPreviousCommandArgs |
|
|
|
] |
|
|
|
}; |
|
|
|