mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-16 18:48:45 -05:00
Fixes uris on nodes
This commit is contained in:
@@ -10,7 +10,7 @@ export class BranchHistoryNode extends ExplorerNode {
|
|||||||
|
|
||||||
readonly resourceType: ResourceType = 'branch-history';
|
readonly resourceType: ResourceType = 'branch-history';
|
||||||
|
|
||||||
constructor(public branch: GitBranch, uri: GitUri, context: ExtensionContext, git: GitService) {
|
constructor(public readonly branch: GitBranch, uri: GitUri, context: ExtensionContext, git: GitService) {
|
||||||
super(uri, context, git);
|
super(uri, context, git);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ export class BranchHistoryNode extends ExplorerNode {
|
|||||||
const log = await this.git.getLogForRepo(this.uri.repoPath!, this.branch.name);
|
const log = await this.git.getLogForRepo(this.uri.repoPath!, this.branch.name);
|
||||||
if (log === undefined) return [];
|
if (log === undefined) return [];
|
||||||
|
|
||||||
return [...Iterables.map(log.commits.values(), c => new CommitNode(c, this.uri, this.context, this.git))];
|
return [...Iterables.map(log.commits.values(), c => new CommitNode(c, this.context, this.git))];
|
||||||
}
|
}
|
||||||
|
|
||||||
getTreeItem(): TreeItem {
|
getTreeItem(): TreeItem {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { ExtensionContext, TreeItem, TreeItemCollapsibleState } from 'vscode';
|
import { ExtensionContext, TreeItem, TreeItemCollapsibleState, Uri } from 'vscode';
|
||||||
import { Commands, DiffWithPreviousCommandArgs } from '../commands';
|
import { Commands, DiffWithPreviousCommandArgs } from '../commands';
|
||||||
import { ExplorerNode, ResourceType } from './explorerNode';
|
import { ExplorerNode, ResourceType } from './explorerNode';
|
||||||
import { getGitStatusIcon, GitCommit, GitService, GitUri, IGitStatusFile, StatusFileFormatter } from '../gitService';
|
import { getGitStatusIcon, GitCommit, GitService, GitUri, IGitStatusFile, StatusFileFormatter } from '../gitService';
|
||||||
@@ -9,8 +9,8 @@ export class CommitFileNode extends ExplorerNode {
|
|||||||
|
|
||||||
readonly resourceType: ResourceType = 'commit-file';
|
readonly resourceType: ResourceType = 'commit-file';
|
||||||
|
|
||||||
constructor(public status: IGitStatusFile, public commit: GitCommit, private template: string, uri: GitUri, context: ExtensionContext, git: GitService) {
|
constructor(public readonly status: IGitStatusFile, public commit: GitCommit, private template: string, context: ExtensionContext, git: GitService) {
|
||||||
super(uri, context, git);
|
super(new GitUri(Uri.file(path.resolve(commit.repoPath, status.fileName)), { repoPath: commit.repoPath, fileName: status.fileName, sha: commit.sha }), context, git);
|
||||||
}
|
}
|
||||||
|
|
||||||
getChildren(): Promise<ExplorerNode[]> {
|
getChildren(): Promise<ExplorerNode[]> {
|
||||||
|
|||||||
@@ -9,8 +9,9 @@ export class CommitNode extends ExplorerNode {
|
|||||||
|
|
||||||
readonly resourceType: ResourceType = 'commit';
|
readonly resourceType: ResourceType = 'commit';
|
||||||
|
|
||||||
constructor(public commit: GitCommit, uri: GitUri, context: ExtensionContext, git: GitService) {
|
constructor(public readonly commit: GitCommit, context: ExtensionContext, git: GitService) {
|
||||||
super(uri, context, git);
|
super(new GitUri(commit.uri, commit), context, git);
|
||||||
|
this.commit = commit;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getChildren(): Promise<ExplorerNode[]> {
|
async getChildren(): Promise<ExplorerNode[]> {
|
||||||
@@ -20,7 +21,7 @@ export class CommitNode extends ExplorerNode {
|
|||||||
const commit = Iterables.first(log.commits.values());
|
const commit = Iterables.first(log.commits.values());
|
||||||
if (commit === undefined) return [];
|
if (commit === undefined) return [];
|
||||||
|
|
||||||
return [...Iterables.map(commit.fileStatuses, s => new CommitFileNode(s, commit, this.git.config.gitExplorer.commitFileFormat, this.uri, this.context, this.git))];
|
return [...Iterables.map(commit.fileStatuses, s => new CommitFileNode(s, commit, this.git.config.gitExplorer.commitFileFormat, this.context, this.git))];
|
||||||
}
|
}
|
||||||
|
|
||||||
getTreeItem(): TreeItem {
|
getTreeItem(): TreeItem {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export abstract class ExplorerNode {
|
|||||||
|
|
||||||
abstract readonly resourceType: ResourceType;
|
abstract readonly resourceType: ResourceType;
|
||||||
|
|
||||||
constructor(public uri: GitUri, protected context: ExtensionContext, protected git: GitService) { }
|
constructor(public readonly uri: GitUri, protected readonly context: ExtensionContext, protected readonly git: GitService) { }
|
||||||
|
|
||||||
abstract getChildren(): ExplorerNode[] | Promise<ExplorerNode[]>;
|
abstract getChildren(): ExplorerNode[] | Promise<ExplorerNode[]>;
|
||||||
abstract getTreeItem(): TreeItem | Promise<TreeItem>;
|
abstract getTreeItem(): TreeItem | Promise<TreeItem>;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export class FileHistoryNode extends 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 [];
|
||||||
|
|
||||||
return [...Iterables.map(log.commits.values(), c => new CommitNode(c, this.uri, this.context, this.git))];
|
return [...Iterables.map(log.commits.values(), c => new CommitNode(c, this.context, this.git))];
|
||||||
}
|
}
|
||||||
|
|
||||||
getTreeItem(): TreeItem {
|
getTreeItem(): TreeItem {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { commands, Event, EventEmitter, ExtensionContext, TreeDataProvider, TreeItem, Uri, window } from 'vscode';
|
import { commands, Event, EventEmitter, ExtensionContext, TreeDataProvider, TreeItem, Uri } from 'vscode';
|
||||||
import { UriComparer } from '../comparers';
|
import { UriComparer } from '../comparers';
|
||||||
import { ExplorerNode, FileHistoryNode, RepositoryNode, ResourceType, StashNode } from './explorerNodes';
|
import { ExplorerNode, FileHistoryNode, RepositoryNode, ResourceType, StashNode } from './explorerNodes';
|
||||||
import { GitService, GitUri } from '../gitService';
|
import { GitService, GitUri } from '../gitService';
|
||||||
@@ -18,12 +18,13 @@ export class GitExplorer implements TreeDataProvider<ExplorerNode> {
|
|||||||
constructor(private context: ExtensionContext, private git: GitService) {
|
constructor(private context: ExtensionContext, private git: GitService) {
|
||||||
commands.registerCommand('gitlens.gitExplorer.refresh', () => this.refresh());
|
commands.registerCommand('gitlens.gitExplorer.refresh', () => this.refresh());
|
||||||
|
|
||||||
const editor = window.activeTextEditor;
|
// const editor = window.activeTextEditor;
|
||||||
|
|
||||||
const uri = (editor !== undefined && editor.document !== undefined)
|
// const uri = (editor !== undefined && editor.document !== undefined)
|
||||||
? new GitUri(editor.document.uri, { repoPath: git.repoPath, fileName: editor.document.uri.fsPath })
|
// ? new GitUri(editor.document.uri, { repoPath: git.repoPath, fileName: editor.document.uri.fsPath })
|
||||||
: new GitUri(Uri.file(git.repoPath), { repoPath: git.repoPath, fileName: git.repoPath });
|
// : new GitUri(Uri.file(git.repoPath), { repoPath: git.repoPath, fileName: git.repoPath });
|
||||||
|
|
||||||
|
const uri = new GitUri(Uri.file(git.repoPath), { repoPath: git.repoPath, fileName: git.repoPath });
|
||||||
this._roots.push(new RepositoryNode(uri, context, git));
|
this._roots.push(new RepositoryNode(uri, context, git));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ export class StashCommitNode extends ExplorerNode {
|
|||||||
|
|
||||||
readonly resourceType: ResourceType = 'stash-commit';
|
readonly resourceType: ResourceType = 'stash-commit';
|
||||||
|
|
||||||
constructor(public commit: GitStashCommit, uri: GitUri, context: ExtensionContext, git: GitService) {
|
constructor(public readonly commit: GitStashCommit, context: ExtensionContext, git: GitService) {
|
||||||
super(uri, context, git);
|
super(new GitUri(commit.uri, commit), context, git);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getChildren(): Promise<CommitFileNode[]> {
|
async getChildren(): Promise<CommitFileNode[]> {
|
||||||
return Promise.resolve((this.commit as GitStashCommit).fileStatuses.map(_ => new CommitFileNode(_, this.commit, this.git.config.stashExplorer.stashFileFormat, this.uri, this.context, this.git)));
|
return Promise.resolve((this.commit as GitStashCommit).fileStatuses.map(_ => new CommitFileNode(_, this.commit, this.git.config.stashExplorer.stashFileFormat, this.context, this.git)));
|
||||||
}
|
}
|
||||||
|
|
||||||
getTreeItem(): TreeItem {
|
getTreeItem(): TreeItem {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { commands, Event, EventEmitter, ExtensionContext, TreeDataProvider, TreeItem, Uri, window } from 'vscode';
|
import { commands, Event, EventEmitter, ExtensionContext, TreeDataProvider, TreeItem, Uri } from 'vscode';
|
||||||
import { ExplorerNode, StashNode } from './explorerNodes';
|
import { ExplorerNode, StashNode } from './explorerNodes';
|
||||||
import { GitService, GitUri } from '../gitService';
|
import { GitService, GitUri } from '../gitService';
|
||||||
import { StashCommitNode } from './stashCommitNode';
|
import { StashCommitNode } from './stashCommitNode';
|
||||||
@@ -17,12 +17,13 @@ export class StashExplorer implements TreeDataProvider<ExplorerNode> {
|
|||||||
constructor(private context: ExtensionContext, private git: GitService) {
|
constructor(private context: ExtensionContext, private git: GitService) {
|
||||||
commands.registerCommand('gitlens.stashExplorer.refresh', () => this.refresh());
|
commands.registerCommand('gitlens.stashExplorer.refresh', () => this.refresh());
|
||||||
|
|
||||||
const editor = window.activeTextEditor;
|
// const editor = window.activeTextEditor;
|
||||||
|
|
||||||
const uri = (editor !== undefined && editor.document !== undefined)
|
// const uri = (editor !== undefined && editor.document !== undefined)
|
||||||
? new GitUri(editor.document.uri, { repoPath: git.repoPath, fileName: editor.document.uri.fsPath })
|
// ? new GitUri(editor.document.uri, { repoPath: git.repoPath, fileName: editor.document.uri.fsPath })
|
||||||
: new GitUri(Uri.file(git.repoPath), { repoPath: git.repoPath, fileName: git.repoPath });
|
// : new GitUri(Uri.file(git.repoPath), { repoPath: git.repoPath, fileName: git.repoPath });
|
||||||
|
|
||||||
|
const uri = new GitUri(Uri.file(git.repoPath), { repoPath: git.repoPath, fileName: git.repoPath });
|
||||||
this._node = new StashNode(uri, this.context, this.git);
|
this._node = new StashNode(uri, this.context, this.git);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export class StashNode extends ExplorerNode {
|
|||||||
const stash = await this.git.getStashList(this.uri.repoPath!);
|
const stash = await this.git.getStashList(this.uri.repoPath!);
|
||||||
if (stash === undefined) return [];
|
if (stash === undefined) return [];
|
||||||
|
|
||||||
return [...Iterables.map(stash.commits.values(), c => new StashCommitNode(c, this.uri, this.context, this.git))];
|
return [...Iterables.map(stash.commits.values(), c => new StashCommitNode(c, this.context, this.git))];
|
||||||
}
|
}
|
||||||
|
|
||||||
getTreeItem(): TreeItem {
|
getTreeItem(): TreeItem {
|
||||||
|
|||||||
Reference in New Issue
Block a user