Browse Source

Fixes uris on nodes

main
Eric Amodio 7 years ago
parent
commit
c96a659e9e
9 changed files with 28 additions and 25 deletions
  1. +2
    -2
      src/views/branchHistoryNode.ts
  2. +4
    -4
      src/views/commitFileNode.ts
  3. +4
    -3
      src/views/commitNode.ts
  4. +1
    -1
      src/views/explorerNode.ts
  5. +1
    -1
      src/views/fileHistoryNode.ts
  6. +6
    -5
      src/views/gitExplorer.ts
  7. +3
    -3
      src/views/stashCommitNode.ts
  8. +6
    -5
      src/views/stashExplorer.ts
  9. +1
    -1
      src/views/stashNode.ts

+ 2
- 2
src/views/branchHistoryNode.ts View File

@ -10,7 +10,7 @@ export class BranchHistoryNode extends ExplorerNode {
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);
}
@ -18,7 +18,7 @@ export class BranchHistoryNode extends ExplorerNode {
const log = await this.git.getLogForRepo(this.uri.repoPath!, this.branch.name);
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 {

+ 4
- 4
src/views/commitFileNode.ts View File

@ -1,5 +1,5 @@
'use strict';
import { ExtensionContext, TreeItem, TreeItemCollapsibleState } from 'vscode';
import { ExtensionContext, TreeItem, TreeItemCollapsibleState, Uri } from 'vscode';
import { Commands, DiffWithPreviousCommandArgs } from '../commands';
import { ExplorerNode, ResourceType } from './explorerNode';
import { getGitStatusIcon, GitCommit, GitService, GitUri, IGitStatusFile, StatusFileFormatter } from '../gitService';
@ -9,8 +9,8 @@ export class CommitFileNode extends ExplorerNode {
readonly resourceType: ResourceType = 'commit-file';
constructor(public status: IGitStatusFile, public commit: GitCommit, private template: string, uri: GitUri, context: ExtensionContext, git: GitService) {
super(uri, context, git);
constructor(public readonly status: IGitStatusFile, public commit: GitCommit, private template: string, context: ExtensionContext, git: GitService) {
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[]> {
@ -49,7 +49,7 @@ export class CommitFileNode extends ExplorerNode {
} as DiffWithPreviousCommandArgs
]
};
return item;
}
}

+ 4
- 3
src/views/commitNode.ts View File

@ -9,8 +9,9 @@ export class CommitNode extends ExplorerNode {
readonly resourceType: ResourceType = 'commit';
constructor(public commit: GitCommit, uri: GitUri, context: ExtensionContext, git: GitService) {
super(uri, context, git);
constructor(public readonly commit: GitCommit, context: ExtensionContext, git: GitService) {
super(new GitUri(commit.uri, commit), context, git);
this.commit = commit;
}
async getChildren(): Promise<ExplorerNode[]> {
@ -20,7 +21,7 @@ export class CommitNode extends ExplorerNode {
const commit = Iterables.first(log.commits.values());
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 {

+ 1
- 1
src/views/explorerNode.ts View File

@ -8,7 +8,7 @@ export abstract class ExplorerNode {
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 getTreeItem(): TreeItem | Promise<TreeItem>;

+ 1
- 1
src/views/fileHistoryNode.ts View File

@ -18,7 +18,7 @@ export class FileHistoryNode extends ExplorerNode {
const log = await this.git.getLogForFile(this.uri.repoPath, this.uri.fsPath, this.uri.sha);
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 {

+ 6
- 5
src/views/gitExplorer.ts View File

@ -1,5 +1,5 @@
'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 { ExplorerNode, FileHistoryNode, RepositoryNode, ResourceType, StashNode } from './explorerNodes';
import { GitService, GitUri } from '../gitService';
@ -18,12 +18,13 @@ export class GitExplorer implements TreeDataProvider {
constructor(private context: ExtensionContext, private git: GitService) {
commands.registerCommand('gitlens.gitExplorer.refresh', () => this.refresh());
const editor = window.activeTextEditor;
// const editor = window.activeTextEditor;
const uri = (editor !== undefined && editor.document !== undefined)
? 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 });
// const uri = (editor !== undefined && editor.document !== undefined)
// ? 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 });
const uri = new GitUri(Uri.file(git.repoPath), { repoPath: git.repoPath, fileName: git.repoPath });
this._roots.push(new RepositoryNode(uri, context, git));
}

+ 3
- 3
src/views/stashCommitNode.ts View File

@ -8,12 +8,12 @@ export class StashCommitNode extends ExplorerNode {
readonly resourceType: ResourceType = 'stash-commit';
constructor(public commit: GitStashCommit, uri: GitUri, context: ExtensionContext, git: GitService) {
super(uri, context, git);
constructor(public readonly commit: GitStashCommit, context: ExtensionContext, git: GitService) {
super(new GitUri(commit.uri, commit), context, git);
}
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 {

+ 6
- 5
src/views/stashExplorer.ts View File

@ -1,5 +1,5 @@
'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 { GitService, GitUri } from '../gitService';
import { StashCommitNode } from './stashCommitNode';
@ -17,12 +17,13 @@ export class StashExplorer implements TreeDataProvider {
constructor(private context: ExtensionContext, private git: GitService) {
commands.registerCommand('gitlens.stashExplorer.refresh', () => this.refresh());
const editor = window.activeTextEditor;
// const editor = window.activeTextEditor;
const uri = (editor !== undefined && editor.document !== undefined)
? 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 });
// const uri = (editor !== undefined && editor.document !== undefined)
// ? 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 });
const uri = new GitUri(Uri.file(git.repoPath), { repoPath: git.repoPath, fileName: git.repoPath });
this._node = new StashNode(uri, this.context, this.git);
}

+ 1
- 1
src/views/stashNode.ts View File

@ -18,7 +18,7 @@ export class StashNode extends ExplorerNode {
const stash = await this.git.getStashList(this.uri.repoPath!);
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 {

Loading…
Cancel
Save