mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-16 10:58:34 -05:00
Adds a file history explorer view
This commit is contained in:
10
README.md
10
README.md
@@ -111,7 +111,9 @@ GitLens provides an unobtrusive blame annotation at the end of the current line,
|
|||||||
|
|
||||||
### Navigate and Explore
|
### Navigate and Explore
|
||||||
|
|
||||||
- Adds a `Git Stashes` explorer to the Explorer activity ([optional](#git-stashes-explorer-settings), off by default)
|
- Adds a [customizable](#git-file-history-explorer-settings) `Git File History` explorer to the Explorer activity -- currently [insiders](#insiders) only
|
||||||
|
|
||||||
|
- Adds a [customizable](#git-stashes-explorer-settings) `Git Stashes` explorer to the Explorer activity
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -289,6 +291,12 @@ GitLens is highly customizable and provides many configuration settings to allow
|
|||||||
|`gitlens.codeLens.customLocationSymbols`|Specifies the set of document symbols where Git code lens will be shown in the document
|
|`gitlens.codeLens.customLocationSymbols`|Specifies the set of document symbols where Git code lens will be shown in the document
|
||||||
|`gitlens.codeLens.perLanguageLocations`|Specifies where Git code lens will be shown in the document for the specified languages
|
|`gitlens.codeLens.perLanguageLocations`|Specifies where Git code lens will be shown in the document for the specified languages
|
||||||
|
|
||||||
|
### Git File History Explorer Settings
|
||||||
|
|
||||||
|
|Name | Description
|
||||||
|
|-----|------------
|
||||||
|
|`gitlens.fileHistoryExplorer.commitFormat`|Specifies the format of committed changes in the `Git File History` explorer <br />Available tokens<br /> ${id} - commit id<br /> ${author} - commit author<br /> ${message} - commit message<br /> ${ago} - relative commit date (e.g. 1 day ago)<br /> ${date} - formatted commit date (format specified by `gitlens.statusBar.dateFormat`)<br /> ${authorAgo} - commit author, relative commit date<br />See https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting for advanced formatting
|
||||||
|
|
||||||
### Git Stashes Explorer Settings
|
### Git Stashes Explorer Settings
|
||||||
|
|
||||||
|Name | Description
|
|Name | Description
|
||||||
|
|||||||
107
package.json
107
package.json
@@ -413,6 +413,11 @@
|
|||||||
"default": null,
|
"default": null,
|
||||||
"description": "Specifies how all absolute dates will be formatted by default\nSee https://momentjs.com/docs/#/displaying/format/ for valid formats"
|
"description": "Specifies how all absolute dates will be formatted by default\nSee https://momentjs.com/docs/#/displaying/format/ for valid formats"
|
||||||
},
|
},
|
||||||
|
"gitlens.fileHistoryExplorer.commitFormat": {
|
||||||
|
"type": "string",
|
||||||
|
"default": "${message} \u00a0\u2022\u00a0 ${authorAgo} \u00a0\u2022\u00a0 ${id}",
|
||||||
|
"description": "Specifies the format of committed changes in the `Git File History` explorer\nAvailable tokens\n ${id} - commit id\n ${author} - commit author\n ${message} - commit message\n ${ago} - relative commit date (e.g. 1 day ago)\n ${date} - formatted commit date (format specified by `gitlens.statusBar.dateFormat`)\n ${authorAgo} - commit author, relative commit date\nSee https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting for advanced formatting"
|
||||||
|
},
|
||||||
"gitlens.stashExplorer.stashFormat": {
|
"gitlens.stashExplorer.stashFormat": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "${message}",
|
"default": "${message}",
|
||||||
@@ -979,6 +984,40 @@
|
|||||||
"light": "images/light/icon-refresh.svg"
|
"light": "images/light/icon-refresh.svg"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "gitlens.fileHistoryExplorer.refresh",
|
||||||
|
"title": "Refresh",
|
||||||
|
"category": "GitLens",
|
||||||
|
"icon": {
|
||||||
|
"dark": "images/dark/icon-refresh.svg",
|
||||||
|
"light": "images/light/icon-refresh.svg"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "gitlens.fileHistoryExplorer.openChanges",
|
||||||
|
"title": "Open Changes",
|
||||||
|
"category": "GitLens"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "gitlens.fileHistoryExplorer.openFile",
|
||||||
|
"title": "Open File",
|
||||||
|
"category": "GitLens"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "gitlens.fileHistoryExplorer.openFileRevision",
|
||||||
|
"title": "Open File Revision",
|
||||||
|
"category": "GitLens"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "gitlens.fileHistoryExplorer.openFileInRemote",
|
||||||
|
"title": "Open File in Remote",
|
||||||
|
"category": "GitLens"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "gitlens.fileHistoryExplorer.openFileRevisionInRemote",
|
||||||
|
"title": "Open File Revision in Remote",
|
||||||
|
"category": "GitLens"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "gitlens.stashExplorer.refresh",
|
"command": "gitlens.stashExplorer.refresh",
|
||||||
"title": "Refresh",
|
"title": "Refresh",
|
||||||
@@ -1163,6 +1202,29 @@
|
|||||||
"command": "gitlens.gitExplorer.refresh",
|
"command": "gitlens.gitExplorer.refresh",
|
||||||
"when": "false"
|
"when": "false"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "gitlens.fileHistoryExplorer.refresh",
|
||||||
|
"when": "false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "gitlens.fileHistoryExplorer.openChanges",
|
||||||
|
"when": "false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "gitlens.fileHistoryExplorer.openFile",
|
||||||
|
"when": "false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "gitlens.fileHistoryExplorer.openFileRevision",
|
||||||
|
"when": "false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "gitlens.fileHistoryExplorer.openFileInRemote",
|
||||||
|
"when": "false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "gitlens.fileHistoryExplorer.openFileRevisionInRemote",
|
||||||
|
"when": "false"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "gitlens.stashExplorer.refresh",
|
"command": "gitlens.stashExplorer.refresh",
|
||||||
@@ -1374,6 +1436,11 @@
|
|||||||
"when": "gitlens:enabled && view == gitlens.gitExplorer",
|
"when": "gitlens:enabled && view == gitlens.gitExplorer",
|
||||||
"group": "navigation"
|
"group": "navigation"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "gitlens.fileHistoryExplorer.refresh",
|
||||||
|
"when": "gitlens:enabled && view == gitlens.fileHistoryExplorer",
|
||||||
|
"group": "navigation"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "gitlens.stashSave",
|
"command": "gitlens.stashSave",
|
||||||
"when": "gitlens:enabled && view == gitlens.stashExplorer",
|
"when": "gitlens:enabled && view == gitlens.stashExplorer",
|
||||||
@@ -1406,6 +1473,41 @@
|
|||||||
"when": "gitlens:enabled && view == gitlens.gitExplorer && viewItem == commit-file",
|
"when": "gitlens:enabled && view == gitlens.gitExplorer && viewItem == commit-file",
|
||||||
"group": "2_gitlens@2"
|
"group": "2_gitlens@2"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "gitlens.fileHistoryExplorer.openChanges",
|
||||||
|
"when": "gitlens:enabled && view == gitlens.fileHistoryExplorer && viewItem == commit-file",
|
||||||
|
"group": "1_gitlens@1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "gitlens.diffWithWorking",
|
||||||
|
"when": "gitlens:enabled && view == gitlens.fileHistoryExplorer && viewItem == commit-file",
|
||||||
|
"group": "1_gitlens@2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "gitlens.fileHistoryExplorer.openFile",
|
||||||
|
"when": "gitlens:enabled && view == gitlens.fileHistoryExplorer && viewItem == commit-file",
|
||||||
|
"group": "2_gitlens@1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "gitlens.fileHistoryExplorer.openFileRevision",
|
||||||
|
"when": "gitlens:enabled && view == gitlens.fileHistoryExplorer && viewItem == commit-file",
|
||||||
|
"group": "2_gitlens@2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "gitlens.fileHistoryExplorer.openFileInRemote",
|
||||||
|
"when": "gitlens:enabled && view == gitlens.fileHistoryExplorer && viewItem == commit-file",
|
||||||
|
"group": "2_gitlens@3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "gitlens.fileHistoryExplorer.openFileRevisionInRemote",
|
||||||
|
"when": "gitlens:enabled && view == gitlens.fileHistoryExplorer && viewItem == commit-file",
|
||||||
|
"group": "2_gitlens@4"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "gitlens.showQuickCommitDetails",
|
||||||
|
"when": "gitlens:enabled && view == gitlens.fileHistoryExplorer && viewItem == commit-file",
|
||||||
|
"group": "3_gitlens@1"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "gitlens.stashApply",
|
"command": "gitlens.stashApply",
|
||||||
"when": "gitlens:enabled && view == gitlens.stashExplorer && viewItem == stash-commit",
|
"when": "gitlens:enabled && view == gitlens.stashExplorer && viewItem == stash-commit",
|
||||||
@@ -1537,6 +1639,11 @@
|
|||||||
],
|
],
|
||||||
"views": {
|
"views": {
|
||||||
"explorer": [
|
"explorer": [
|
||||||
|
{
|
||||||
|
"id": "gitlens.fileHistoryExplorer",
|
||||||
|
"name": "Git File History",
|
||||||
|
"when": "gitlens:enabled && config.gitlens.insiders"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "gitlens.stashExplorer",
|
"id": "gitlens.stashExplorer",
|
||||||
"name": "Git Stashes",
|
"name": "Git Stashes",
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { Strings } from '../system';
|
import { Strings } from '../system';
|
||||||
import { commands, TextEditor, Uri, window } from 'vscode';
|
import { commands, TextEditor, Uri, window } from 'vscode';
|
||||||
import { ActiveEditorCachedCommand, Commands, getCommandUri } from './common';
|
import { ActiveEditorCachedCommand, CommandContext, Commands, getCommandUri } from './common';
|
||||||
import { GlyphChars } from '../constants';
|
import { GlyphChars } from '../constants';
|
||||||
|
import { CommitNode } from '../views/explorerNodes';
|
||||||
import { GitCommit, GitLog, GitLogCommit, GitService, GitUri } from '../gitService';
|
import { GitCommit, GitLog, GitLogCommit, GitService, GitUri } from '../gitService';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import { CommandQuickPickItem, CommitDetailsQuickPick, CommitWithFileStatusQuickPickItem } from '../quickPicks';
|
import { CommandQuickPickItem, CommitDetailsQuickPick, CommitWithFileStatusQuickPickItem } from '../quickPicks';
|
||||||
@@ -24,6 +25,18 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand {
|
|||||||
super(Commands.ShowQuickCommitDetails);
|
super(Commands.ShowQuickCommitDetails);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected async preExecute(context: CommandContext, ...args: any[]): Promise<any> {
|
||||||
|
if (context.type === 'view') {
|
||||||
|
if (context.node instanceof CommitNode) {
|
||||||
|
args = [{ sha: context.node.uri.sha, commit: context.node.commit }];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
args = [{ sha: context.node.uri.sha }];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this.execute(context.editor, context.uri, ...args);
|
||||||
|
}
|
||||||
|
|
||||||
async execute(editor?: TextEditor, uri?: Uri, args: ShowQuickCommitDetailsCommandArgs = {}) {
|
async execute(editor?: TextEditor, uri?: Uri, args: ShowQuickCommitDetailsCommandArgs = {}) {
|
||||||
uri = getCommandUri(uri, editor);
|
uri = getCommandUri(uri, editor);
|
||||||
if (uri === undefined) return undefined;
|
if (uri === undefined) return undefined;
|
||||||
|
|||||||
@@ -296,6 +296,12 @@ export interface IConfig {
|
|||||||
|
|
||||||
defaultDateFormat: string | null;
|
defaultDateFormat: string | null;
|
||||||
|
|
||||||
|
fileHistoryExplorer: {
|
||||||
|
commitFormat: string;
|
||||||
|
// commitFileFormat: string;
|
||||||
|
// dateFormat: string | null;
|
||||||
|
};
|
||||||
|
|
||||||
gitExplorer: {
|
gitExplorer: {
|
||||||
commitFormat: string;
|
commitFormat: string;
|
||||||
commitFileFormat: string;
|
commitFileFormat: string;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import { CodeLensController } from './codeLensController';
|
|||||||
import { CurrentLineController, LineAnnotationType } from './currentLineController';
|
import { CurrentLineController, LineAnnotationType } from './currentLineController';
|
||||||
import { GitContentProvider } from './gitContentProvider';
|
import { GitContentProvider } from './gitContentProvider';
|
||||||
// import { GitExplorer } from './views/gitExplorer';
|
// import { GitExplorer } from './views/gitExplorer';
|
||||||
|
import { FileHistoryExplorer } from './views/fileHistoryExplorer';
|
||||||
import { StashExplorer } from './views/stashExplorer';
|
import { StashExplorer } from './views/stashExplorer';
|
||||||
import { GitRevisionCodeLensProvider } from './gitRevisionCodeLensProvider';
|
import { GitRevisionCodeLensProvider } from './gitRevisionCodeLensProvider';
|
||||||
import { GitContextTracker, GitService } from './gitService';
|
import { GitContextTracker, GitService } from './gitService';
|
||||||
@@ -96,6 +97,7 @@ export async function activate(context: ExtensionContext) {
|
|||||||
// const explorer = new GitExplorer(context, git);
|
// const explorer = new GitExplorer(context, git);
|
||||||
// context.subscriptions.push(window.registerTreeDataProvider('gitlens.gitExplorer', explorer));
|
// context.subscriptions.push(window.registerTreeDataProvider('gitlens.gitExplorer', explorer));
|
||||||
|
|
||||||
|
context.subscriptions.push(window.registerTreeDataProvider('gitlens.fileHistoryExplorer', new FileHistoryExplorer(context, git)));
|
||||||
context.subscriptions.push(window.registerTreeDataProvider('gitlens.stashExplorer', new StashExplorer(context, git)));
|
context.subscriptions.push(window.registerTreeDataProvider('gitlens.stashExplorer', new StashExplorer(context, git)));
|
||||||
|
|
||||||
context.subscriptions.push(commands.registerTextEditorCommand('gitlens.computingFileAnnotations', () => { }));
|
context.subscriptions.push(commands.registerTextEditorCommand('gitlens.computingFileAnnotations', () => { }));
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { Iterables } from '../system';
|
import { Iterables } from '../system';
|
||||||
import { ExtensionContext, TreeItem, TreeItemCollapsibleState } from 'vscode';
|
import { Command, ExtensionContext, TreeItem, TreeItemCollapsibleState } from 'vscode';
|
||||||
|
import { Commands, DiffWithPreviousCommandArgs } from '../commands';
|
||||||
import { CommitFileNode } from './commitFileNode';
|
import { CommitFileNode } from './commitFileNode';
|
||||||
import { ExplorerNode, ResourceType } from './explorerNode';
|
import { ExplorerNode, ResourceType } from './explorerNode';
|
||||||
import { CommitFormatter, GitCommit, GitService, GitUri } from '../gitService';
|
import { CommitFormatter, GitCommit, GitService, GitUri } from '../gitService';
|
||||||
@@ -14,6 +15,8 @@ export class CommitNode extends ExplorerNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getChildren(): Promise<ExplorerNode[]> {
|
async getChildren(): Promise<ExplorerNode[]> {
|
||||||
|
if (this.commit.type === 'file') Promise.resolve([]);
|
||||||
|
|
||||||
const log = await this.git.getLogForRepo(this.commit.repoPath, this.commit.sha, 1);
|
const log = await this.git.getLogForRepo(this.commit.repoPath, this.commit.sha, 1);
|
||||||
if (log === undefined) return [];
|
if (log === undefined) return [];
|
||||||
|
|
||||||
@@ -24,14 +27,40 @@ export class CommitNode extends ExplorerNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getTreeItem(): TreeItem {
|
getTreeItem(): TreeItem {
|
||||||
const label = CommitFormatter.fromTemplate(this.template, this.commit, this.git.config.defaultDateFormat);
|
const item = new TreeItem(CommitFormatter.fromTemplate(this.template, this.commit, this.git.config.defaultDateFormat));
|
||||||
|
if (this.commit.type === 'file') {
|
||||||
|
item.collapsibleState = TreeItemCollapsibleState.None;
|
||||||
|
item.command = this.getCommand();
|
||||||
|
item.contextValue = 'commit-file';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
item.collapsibleState = TreeItemCollapsibleState.Collapsed;
|
||||||
|
item.contextValue = this.resourceType;
|
||||||
|
}
|
||||||
|
|
||||||
const item = new TreeItem(label, TreeItemCollapsibleState.Collapsed);
|
|
||||||
item.contextValue = this.resourceType;
|
|
||||||
item.iconPath = {
|
item.iconPath = {
|
||||||
dark: this.context.asAbsolutePath('images/dark/icon-commit.svg'),
|
dark: this.context.asAbsolutePath('images/dark/icon-commit.svg'),
|
||||||
light: this.context.asAbsolutePath('images/light/icon-commit.svg')
|
light: this.context.asAbsolutePath('images/light/icon-commit.svg')
|
||||||
};
|
};
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getCommand(): Command | undefined {
|
||||||
|
return {
|
||||||
|
title: 'Compare File with Previous',
|
||||||
|
command: Commands.DiffWithPrevious,
|
||||||
|
arguments: [
|
||||||
|
new GitUri(this.uri, this.commit),
|
||||||
|
{
|
||||||
|
commit: this.commit,
|
||||||
|
line: 0,
|
||||||
|
showOptions: {
|
||||||
|
preserveFocus: true,
|
||||||
|
preview: true
|
||||||
|
}
|
||||||
|
} as DiffWithPreviousCommandArgs
|
||||||
|
]
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
89
src/views/fileHistoryExplorer.ts
Normal file
89
src/views/fileHistoryExplorer.ts
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
'use strict';
|
||||||
|
// import { Arrays } from '../system';
|
||||||
|
import { commands, Event, EventEmitter, ExtensionContext, TextEditor, TreeDataProvider, TreeItem, Uri, window } from 'vscode';
|
||||||
|
import { Commands, DiffWithPreviousCommandArgs, openEditor, OpenFileInRemoteCommandArgs } from '../commands';
|
||||||
|
import { UriComparer } from '../comparers';
|
||||||
|
import { CommitNode, ExplorerNode, FileHistoryNode, TextExplorerNode } from './explorerNodes';
|
||||||
|
import { GitService, GitUri } from '../gitService';
|
||||||
|
|
||||||
|
export * from './explorerNodes';
|
||||||
|
|
||||||
|
export class FileHistoryExplorer implements TreeDataProvider<ExplorerNode> {
|
||||||
|
|
||||||
|
private _node?: ExplorerNode;
|
||||||
|
|
||||||
|
private _onDidChangeTreeData = new EventEmitter<ExplorerNode>();
|
||||||
|
public get onDidChangeTreeData(): Event<ExplorerNode> {
|
||||||
|
return this._onDidChangeTreeData.event;
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(private context: ExtensionContext, private git: GitService) {
|
||||||
|
commands.registerCommand('gitlens.fileHistoryExplorer.refresh', this.refresh, this);
|
||||||
|
commands.registerCommand('gitlens.fileHistoryExplorer.openChanges', this.openChanges, this);
|
||||||
|
commands.registerCommand('gitlens.fileHistoryExplorer.openFile', this.openFile, this);
|
||||||
|
commands.registerCommand('gitlens.fileHistoryExplorer.openFileRevision', this.openFileRevision, this);
|
||||||
|
commands.registerCommand('gitlens.fileHistoryExplorer.openFileInRemote', this.openFileInRemote, this);
|
||||||
|
commands.registerCommand('gitlens.fileHistoryExplorer.openFileRevisionInRemote', this.openFileRevisionInRemote, this);
|
||||||
|
|
||||||
|
context.subscriptions.push(window.onDidChangeActiveTextEditor(this.onActiveEditorChanged, this));
|
||||||
|
|
||||||
|
this._node = this.getRootNode(window.activeTextEditor);
|
||||||
|
}
|
||||||
|
|
||||||
|
async getTreeItem(node: ExplorerNode): Promise<TreeItem> {
|
||||||
|
return node.getTreeItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
async getChildren(node?: ExplorerNode): Promise<ExplorerNode[]> {
|
||||||
|
if (this._node === undefined) return [new TextExplorerNode('No active file')];
|
||||||
|
if (node === undefined) return this._node.getChildren();
|
||||||
|
return node.getChildren();
|
||||||
|
}
|
||||||
|
|
||||||
|
private getRootNode(editor: TextEditor | undefined): ExplorerNode | undefined {
|
||||||
|
if (window.visibleTextEditors.length === 0) return undefined;
|
||||||
|
if (editor === undefined) return this._node;
|
||||||
|
|
||||||
|
const uri = this.git.getGitUriForFile(editor.document.uri) || new GitUri(editor.document.uri, { repoPath: this.git.repoPath, fileName: editor.document.uri.fsPath });
|
||||||
|
if (UriComparer.equals(uri, this._node && this._node.uri)) return this._node;
|
||||||
|
|
||||||
|
return new FileHistoryNode(uri, this.context, this.git);
|
||||||
|
}
|
||||||
|
|
||||||
|
private onActiveEditorChanged(editor: TextEditor | undefined) {
|
||||||
|
const node = this.getRootNode(editor);
|
||||||
|
if (node === this._node) return;
|
||||||
|
|
||||||
|
this.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
refresh(node?: ExplorerNode) {
|
||||||
|
this._node = node || this.getRootNode(window.activeTextEditor);
|
||||||
|
this._onDidChangeTreeData.fire();
|
||||||
|
}
|
||||||
|
|
||||||
|
private openChanges(node: CommitNode) {
|
||||||
|
const command = node.getCommand();
|
||||||
|
if (command === undefined || command.arguments === undefined) return;
|
||||||
|
|
||||||
|
const [uri, args] = command.arguments as [Uri, DiffWithPreviousCommandArgs];
|
||||||
|
args.showOptions!.preview = false;
|
||||||
|
return commands.executeCommand(command.command, uri, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
private openFile(node: CommitNode) {
|
||||||
|
return openEditor(node.uri, { preserveFocus: true, preview: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
private openFileRevision(node: CommitNode) {
|
||||||
|
return openEditor(GitService.toGitContentUri(node.uri), { preserveFocus: true, preview: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
private async openFileInRemote(node: CommitNode) {
|
||||||
|
return commands.executeCommand(Commands.OpenFileInRemote, node.commit.uri, { range: false } as OpenFileInRemoteCommandArgs);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async openFileRevisionInRemote(node: CommitNode) {
|
||||||
|
return commands.executeCommand(Commands.OpenFileInRemote, new GitUri(node.commit.uri, node.commit), { range: false } as OpenFileInRemoteCommandArgs);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,11 +14,11 @@ export class FileHistoryNode extends ExplorerNode {
|
|||||||
super(uri);
|
super(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getChildren(): Promise<CommitNode[]> {
|
async getChildren(): Promise<ExplorerNode[]> {
|
||||||
const log = await this.git.getLogForFile(this.uri.repoPath, this.uri.fsPath, this.uri.sha);
|
const log = await this.git.getLogForFile(this.uri.repoPath, this.uri.fsPath, this.uri.sha);
|
||||||
if (log === undefined) return [];
|
if (log === undefined) return [new TextExplorerNode('No file history')];
|
||||||
|
|
||||||
return [...Iterables.map(log.commits.values(), c => new CommitNode(c, this.git.config.gitExplorer.commitFormat, this.context, this.git))];
|
return [...Iterables.map(log.commits.values(), c => new CommitNode(c, this.git.config.fileHistoryExplorer.commitFormat, this.context, this.git))];
|
||||||
}
|
}
|
||||||
|
|
||||||
getTreeItem(): TreeItem {
|
getTreeItem(): TreeItem {
|
||||||
|
|||||||
Reference in New Issue
Block a user