瀏覽代碼

Adds parent links to all nodes

When tracking the active file, only select the repo if in another
main
Eric Amodio 6 年之前
父節點
當前提交
8ea92332c4
共有 32 個檔案被更改,包括 206 行新增142 行删除
  1. +8
    -2
      src/views/explorer.ts
  2. +8
    -7
      src/views/nodes/branchNode.ts
  3. +6
    -4
      src/views/nodes/branchOrTagFolderNode.ts
  4. +14
    -5
      src/views/nodes/branchesNode.ts
  5. +3
    -2
      src/views/nodes/commitFileNode.ts
  6. +5
    -4
      src/views/nodes/commitNode.ts
  7. +9
    -7
      src/views/nodes/common.ts
  8. +9
    -2
      src/views/nodes/explorerNode.ts
  9. +5
    -5
      src/views/nodes/fileHistoryNode.ts
  10. +3
    -3
      src/views/nodes/fileHistoryTrackerNode.ts
  11. +4
    -3
      src/views/nodes/folderNode.ts
  12. +9
    -4
      src/views/nodes/lineHistoryNode.ts
  13. +3
    -3
      src/views/nodes/lineHistoryTrackerNode.ts
  14. +6
    -4
      src/views/nodes/remoteNode.ts
  15. +6
    -5
      src/views/nodes/remotesNode.ts
  16. +15
    -5
      src/views/nodes/repositoriesNode.ts
  17. +11
    -10
      src/views/nodes/repositoryNode.ts
  18. +3
    -3
      src/views/nodes/resultsCommitNode.ts
  19. +9
    -8
      src/views/nodes/resultsCommitsNode.ts
  20. +4
    -4
      src/views/nodes/resultsComparisonNode.ts
  21. +2
    -2
      src/views/nodes/resultsNode.ts
  22. +3
    -3
      src/views/nodes/stashFileNode.ts
  23. +4
    -3
      src/views/nodes/stashNode.ts
  24. +6
    -5
      src/views/nodes/stashesNode.ts
  25. +4
    -2
      src/views/nodes/statusFileCommitsNode.ts
  26. +13
    -12
      src/views/nodes/statusFileNode.ts
  27. +5
    -3
      src/views/nodes/statusFilesNode.ts
  28. +11
    -7
      src/views/nodes/statusFilesResultsNode.ts
  29. +5
    -4
      src/views/nodes/statusUpstreamNode.ts
  30. +5
    -4
      src/views/nodes/tagNode.ts
  31. +7
    -6
      src/views/nodes/tagsNode.ts
  32. +1
    -1
      src/views/resultsExplorer.ts

+ 8
- 2
src/views/explorer.ts 查看文件

@ -90,8 +90,8 @@ export abstract class ExplorerBase implements TreeDa
return this._root.getChildren(); return this._root.getChildren();
} }
getParent(): ExplorerNode | undefined {
return undefined;
getParent(node: ExplorerNode): ExplorerNode | undefined {
return node.getParent();
} }
getTreeItem(node: ExplorerNode): TreeItem | Promise<TreeItem> { getTreeItem(node: ExplorerNode): TreeItem | Promise<TreeItem> {
@ -102,6 +102,12 @@ export abstract class ExplorerBase implements TreeDa
this._onDidChangeVisibility.fire(e); this._onDidChangeVisibility.fire(e);
} }
get selection(): ExplorerNode[] {
if (this._tree === undefined || this._root === undefined) return [];
return this._tree.selection;
}
get visible(): boolean { get visible(): boolean {
return this._tree !== undefined ? this._tree.visible : false; return this._tree !== undefined ? this._tree.visible : false;
} }

+ 8
- 7
src/views/nodes/branchNode.ts 查看文件

@ -19,16 +19,17 @@ export class BranchNode extends ExplorerRefNode implements PageableExplorerNode
constructor( constructor(
public readonly branch: GitBranch, public readonly branch: GitBranch,
uri: GitUri, uri: GitUri,
protected readonly explorer: GitExplorer,
private readonly markCurrent: boolean = true
parent: ExplorerNode,
public readonly explorer: GitExplorer,
private readonly _markCurrent: boolean = true
) { ) {
super(uri);
super(uri, parent);
} }
get id(): string { get id(): string {
return `gitlens:repository(${this.branch.repoPath}):branch(${this.branch.name})${ return `gitlens:repository(${this.branch.repoPath}):branch(${this.branch.name})${
this.branch.remote ? ':remote' : '' this.branch.remote ? ':remote' : ''
}${this.markCurrent ? ':current' : ''}`;
}${this._markCurrent ? ':current' : ''}`;
} }
get current(): boolean { get current(): boolean {
@ -52,7 +53,7 @@ export class BranchNode extends ExplorerRefNode implements PageableExplorerNode
maxCount: this.maxCount || this.explorer.config.defaultItemLimit, maxCount: this.maxCount || this.explorer.config.defaultItemLimit,
ref: this.ref ref: this.ref
}); });
if (log === undefined) return [new MessageNode('No commits yet')];
if (log === undefined) return [new MessageNode(this, 'No commits yet')];
const branches = await Container.git.getBranches(this.uri.repoPath); const branches = await Container.git.getBranches(this.uri.repoPath);
// Get the sha length, since `git branch` can return variable length shas // Get the sha length, since `git branch` can return variable length shas
@ -72,7 +73,7 @@ export class BranchNode extends ExplorerRefNode implements PageableExplorerNode
const children: (CommitNode | ShowMoreNode)[] = [ const children: (CommitNode | ShowMoreNode)[] = [
...Iterables.map( ...Iterables.map(
log.commits.values(), log.commits.values(),
c => new CommitNode(c, this.explorer, this.branch, getBranchTips)
c => new CommitNode(c, this, this.explorer, this.branch, getBranchTips)
) )
]; ];
@ -113,7 +114,7 @@ export class BranchNode extends ExplorerRefNode implements PageableExplorerNode
} }
const item = new TreeItem( const item = new TreeItem(
`${this.markCurrent && this.current ? `${GlyphChars.Check} ${GlyphChars.Space}` : ''}${name}`,
`${this._markCurrent && this.current ? `${GlyphChars.Check} ${GlyphChars.Space}` : ''}${name}`,
TreeItemCollapsibleState.Collapsed TreeItemCollapsibleState.Collapsed
); );
item.id = this.id; item.id = this.id;

+ 6
- 4
src/views/nodes/branchOrTagFolderNode.ts 查看文件

@ -14,10 +14,11 @@ export class BranchOrTagFolderNode extends ExplorerNode {
public readonly folderName: string, public readonly folderName: string,
public readonly relativePath: string | undefined, public readonly relativePath: string | undefined,
public readonly root: Arrays.IHierarchicalItem<BranchNode | TagNode>, public readonly root: Arrays.IHierarchicalItem<BranchNode | TagNode>,
private readonly explorer: Explorer,
private readonly expanded: boolean = false
parent: ExplorerNode,
public readonly explorer: Explorer,
private readonly _expanded: boolean = false
) { ) {
super(GitUri.fromRepoPath(repoPath));
super(GitUri.fromRepoPath(repoPath), parent);
} }
get id(): string { get id(): string {
@ -42,6 +43,7 @@ export class BranchOrTagFolderNode extends ExplorerNode {
folder.name, folder.name,
folder.relativePath, folder.relativePath,
folder, folder,
this,
this.explorer, this.explorer,
expanded expanded
) )
@ -58,7 +60,7 @@ export class BranchOrTagFolderNode extends ExplorerNode {
async getTreeItem(): Promise<TreeItem> { async getTreeItem(): Promise<TreeItem> {
const item = new TreeItem( const item = new TreeItem(
this.label, this.label,
this.expanded ? TreeItemCollapsibleState.Expanded : TreeItemCollapsibleState.Collapsed
this._expanded ? TreeItemCollapsibleState.Expanded : TreeItemCollapsibleState.Collapsed
); );
item.id = this.id; item.id = this.id;
item.contextValue = ResourceType.Folder; item.contextValue = ResourceType.Folder;

+ 14
- 5
src/views/nodes/branchesNode.ts 查看文件

@ -14,10 +14,11 @@ export class BranchesNode extends ExplorerNode {
constructor( constructor(
uri: GitUri, uri: GitUri,
private readonly repo: Repository,
private readonly explorer: GitExplorer
public readonly repo: Repository,
parent: ExplorerNode,
public readonly explorer: GitExplorer
) { ) {
super(uri);
super(uri, parent);
} }
get id(): string { get id(): string {
@ -35,7 +36,7 @@ export class BranchesNode extends ExplorerNode {
const branchNodes = [ const branchNodes = [
...Iterables.filterMap( ...Iterables.filterMap(
branches, branches,
b => (b.remote ? undefined : new BranchNode(b, this.uri, this.explorer))
b => (b.remote ? undefined : new BranchNode(b, this.uri, this, this.explorer))
) )
]; ];
if (this.explorer.config.branches.layout === ExplorerBranchesLayout.List) return branchNodes; if (this.explorer.config.branches.layout === ExplorerBranchesLayout.List) return branchNodes;
@ -47,7 +48,15 @@ export class BranchesNode extends ExplorerNode {
this.explorer.config.files.compact this.explorer.config.files.compact
); );
const root = new BranchOrTagFolderNode('branch', this.repo.path, '', undefined, hierarchy, this.explorer);
const root = new BranchOrTagFolderNode(
'branch',
this.repo.path,
'',
undefined,
hierarchy,
this,
this.explorer
);
this._children = await root.getChildren(); this._children = await root.getChildren();
} }
return this._children; return this._children;

+ 3
- 2
src/views/nodes/commitFileNode.ts 查看文件

@ -34,11 +34,12 @@ export class CommitFileNode extends ExplorerRefNode {
constructor( constructor(
public readonly status: IGitStatusFile, public readonly status: IGitStatusFile,
public commit: GitLogCommit, public commit: GitLogCommit,
protected readonly explorer: Explorer,
parent: ExplorerNode,
public readonly explorer: Explorer,
private readonly _displayAs: CommitFileNodeDisplayAs, private readonly _displayAs: CommitFileNodeDisplayAs,
private readonly _selection?: Selection private readonly _selection?: Selection
) { ) {
super(GitUri.fromFileStatus(status, commit.repoPath, commit.sha));
super(GitUri.fromFileStatus(status, commit.repoPath, commit.sha), parent);
} }
get ref(): string { get ref(): string {

+ 5
- 4
src/views/nodes/commitNode.ts 查看文件

@ -15,11 +15,12 @@ import { FolderNode, IFileExplorerNode } from './folderNode';
export class CommitNode extends ExplorerRefNode { export class CommitNode extends ExplorerRefNode {
constructor( constructor(
public readonly commit: GitLogCommit, public readonly commit: GitLogCommit,
private readonly explorer: Explorer,
parent: ExplorerNode,
public readonly explorer: Explorer,
public readonly branch?: GitBranch, public readonly branch?: GitBranch,
private readonly getBranchTips?: (sha: string) => string | undefined private readonly getBranchTips?: (sha: string) => string | undefined
) { ) {
super(commit.toGitUri());
super(commit.toGitUri(), parent);
} }
get ref(): string { get ref(): string {
@ -31,7 +32,7 @@ export class CommitNode extends ExplorerRefNode {
let children: IFileExplorerNode[] = [ let children: IFileExplorerNode[] = [
...Iterables.map( ...Iterables.map(
commit.fileStatuses, commit.fileStatuses,
s => new CommitFileNode(s, commit.toFileCommit(s), this.explorer, CommitFileNodeDisplayAs.File)
s => new CommitFileNode(s, commit.toFileCommit(s), this, this.explorer, CommitFileNodeDisplayAs.File)
) )
]; ];
@ -43,7 +44,7 @@ export class CommitNode extends ExplorerRefNode {
this.explorer.config.files.compact this.explorer.config.files.compact
); );
const root = new FolderNode(this.repoPath, '', undefined, hierarchy, this.explorer);
const root = new FolderNode(this.repoPath, '', undefined, hierarchy, this, this.explorer);
children = (await root.getChildren()) as IFileExplorerNode[]; children = (await root.getChildren()) as IFileExplorerNode[];
} }
else { else {

+ 9
- 7
src/views/nodes/common.ts 查看文件

@ -7,6 +7,7 @@ import { ExplorerNode, ResourceType, unknownGitUri } from '../nodes/explorerNode
export class MessageNode extends ExplorerNode { export class MessageNode extends ExplorerNode {
constructor( constructor(
parent: ExplorerNode,
private readonly _message: string, private readonly _message: string,
private readonly _tooltip?: string, private readonly _tooltip?: string,
private readonly _iconPath?: private readonly _iconPath?:
@ -18,7 +19,7 @@ export class MessageNode extends ExplorerNode {
} }
| ThemeIcon | ThemeIcon
) { ) {
super(unknownGitUri);
super(unknownGitUri, parent);
} }
getChildren(): ExplorerNode[] | Promise<ExplorerNode[]> { getChildren(): ExplorerNode[] | Promise<ExplorerNode[]> {
@ -36,6 +37,7 @@ export class MessageNode extends ExplorerNode {
export class UpdateableMessageNode extends ExplorerNode { export class UpdateableMessageNode extends ExplorerNode {
constructor( constructor(
parent: ExplorerNode,
public readonly id: string, public readonly id: string,
private _message: string, private _message: string,
private _tooltip?: string, private _tooltip?: string,
@ -48,7 +50,7 @@ export class UpdateableMessageNode extends ExplorerNode {
} }
| ThemeIcon | ThemeIcon
) { ) {
super(unknownGitUri);
super(unknownGitUri, parent);
} }
getChildren(): ExplorerNode[] | Promise<ExplorerNode[]> { getChildren(): ExplorerNode[] | Promise<ExplorerNode[]> {
@ -101,10 +103,10 @@ export abstract class PagerNode extends ExplorerNode {
constructor( constructor(
protected readonly message: string, protected readonly message: string,
protected readonly node: ExplorerNode,
protected readonly parent: ExplorerNode,
protected readonly explorer: Explorer protected readonly explorer: Explorer
) { ) {
super(unknownGitUri);
super(unknownGitUri, parent);
} }
getChildren(): ExplorerNode[] | Promise<ExplorerNode[]> { getChildren(): ExplorerNode[] | Promise<ExplorerNode[]> {
@ -126,7 +128,7 @@ export abstract class PagerNode extends ExplorerNode {
return { return {
title: 'Refresh', title: 'Refresh',
command: this.explorer.getQualifiedCommand('refreshNode'), command: this.explorer.getQualifiedCommand('refreshNode'),
arguments: [this.node, this._args]
arguments: [this.parent, this._args]
} as Command; } as Command;
} }
} }
@ -134,7 +136,7 @@ export abstract class PagerNode extends ExplorerNode {
export class ShowMoreNode extends PagerNode { export class ShowMoreNode extends PagerNode {
constructor( constructor(
type: string, type: string,
node: ExplorerNode,
parent: ExplorerNode,
explorer: Explorer, explorer: Explorer,
maxCount: number = Container.config.advanced.maxListItems maxCount: number = Container.config.advanced.maxListItems
) { ) {
@ -142,7 +144,7 @@ export class ShowMoreNode extends PagerNode {
maxCount === 0 maxCount === 0
? `Show All ${type} ${GlyphChars.Space}${GlyphChars.Dash}${GlyphChars.Space} this may take a while` ? `Show All ${type} ${GlyphChars.Space}${GlyphChars.Dash}${GlyphChars.Space} this may take a while`
: `Show More ${type}`, : `Show More ${type}`,
node,
parent,
explorer explorer
); );
this._args.maxCount = maxCount; this._args.maxCount = maxCount;

+ 9
- 2
src/views/nodes/explorerNode.ts 查看文件

@ -49,7 +49,10 @@ export interface NamedRef {
export const unknownGitUri = new GitUri(); export const unknownGitUri = new GitUri();
export abstract class ExplorerNode { export abstract class ExplorerNode {
constructor(uri: GitUri) {
constructor(
uri: GitUri,
private readonly _parent: ExplorerNode | undefined
) {
this._uri = uri; this._uri = uri;
} }
@ -59,6 +62,9 @@ export abstract class ExplorerNode {
} }
abstract getChildren(): ExplorerNode[] | Promise<ExplorerNode[]>; abstract getChildren(): ExplorerNode[] | Promise<ExplorerNode[]>;
getParent(): ExplorerNode | undefined {
return this._parent;
}
abstract getTreeItem(): TreeItem | Promise<TreeItem>; abstract getTreeItem(): TreeItem | Promise<TreeItem>;
getCommand(): Command | undefined { getCommand(): Command | undefined {
@ -99,9 +105,10 @@ export abstract class SubscribeableExplorerNode exte
constructor( constructor(
uri: GitUri, uri: GitUri,
parent: ExplorerNode | undefined,
public readonly explorer: TExplorer public readonly explorer: TExplorer
) { ) {
super(uri);
super(uri, parent);
const disposables = [this.explorer.onDidChangeVisibility(this.onVisibilityChanged, this)]; const disposables = [this.explorer.onDidChangeVisibility(this.onVisibilityChanged, this)];

+ 5
- 5
src/views/nodes/fileHistoryNode.ts 查看文件

@ -18,8 +18,8 @@ import { MessageNode } from './common';
import { ExplorerNode, ResourceType, SubscribeableExplorerNode } from './explorerNode'; import { ExplorerNode, ResourceType, SubscribeableExplorerNode } from './explorerNode';
export class FileHistoryNode extends SubscribeableExplorerNode<FileHistoryExplorer> { export class FileHistoryNode extends SubscribeableExplorerNode<FileHistoryExplorer> {
constructor(uri: GitUri, explorer: FileHistoryExplorer) {
super(uri, explorer);
constructor(uri: GitUri, parent: ExplorerNode, explorer: FileHistoryExplorer) {
super(uri, parent, explorer);
} }
async getChildren(): Promise<ExplorerNode[]> { async getChildren(): Promise<ExplorerNode[]> {
@ -63,7 +63,7 @@ export class FileHistoryNode extends SubscribeableExplorerNode
previousSha, previousSha,
status.originalFileName || status.fileName status.originalFileName || status.fileName
); );
children.push(new CommitFileNode(status, commit, this.explorer, displayAs));
children.push(new CommitFileNode(status, commit, this, this.explorer, displayAs));
} }
const log = await Container.git.getLogForFile(this.uri.repoPath, this.uri.fsPath, { ref: this.uri.sha }); const log = await Container.git.getLogForFile(this.uri.repoPath, this.uri.fsPath, { ref: this.uri.sha });
@ -71,12 +71,12 @@ export class FileHistoryNode extends SubscribeableExplorerNode
children.push( children.push(
...Iterables.map( ...Iterables.map(
log.commits.values(), log.commits.values(),
c => new CommitFileNode(c.fileStatuses[0], c, this.explorer, displayAs)
c => new CommitFileNode(c.fileStatuses[0], c, this, this.explorer, displayAs)
) )
); );
} }
if (children.length === 0) return [new MessageNode('No file history')];
if (children.length === 0) return [new MessageNode(this, 'No file history')];
return children; return children;
} }

+ 3
- 3
src/views/nodes/fileHistoryTrackerNode.ts 查看文件

@ -14,7 +14,7 @@ export class FileHistoryTrackerNode extends SubscribeableExplorerNode
private _child: FileHistoryNode | undefined; private _child: FileHistoryNode | undefined;
constructor(explorer: FileHistoryExplorer) { constructor(explorer: FileHistoryExplorer) {
super(unknownGitUri, explorer);
super(unknownGitUri, undefined, explorer);
} }
dispose() { dispose() {
@ -33,10 +33,10 @@ export class FileHistoryTrackerNode extends SubscribeableExplorerNode
async getChildren(): Promise<ExplorerNode[]> { async getChildren(): Promise<ExplorerNode[]> {
if (this._child === undefined) { if (this._child === undefined) {
if (this.uri === unknownGitUri) { if (this.uri === unknownGitUri) {
return [new MessageNode('There are no editors open that can provide file history')];
return [new MessageNode(this, 'There are no editors open that can provide file history')];
} }
this._child = new FileHistoryNode(this.uri, this.explorer);
this._child = new FileHistoryNode(this.uri, this, this.explorer);
} }
return [this._child]; return [this._child];

+ 4
- 3
src/views/nodes/folderNode.ts 查看文件

@ -22,9 +22,10 @@ export class FolderNode extends ExplorerNode {
public readonly folderName: string, public readonly folderName: string,
public readonly relativePath: string | undefined, public readonly relativePath: string | undefined,
public readonly root: Arrays.IHierarchicalItem<IFileExplorerNode>, public readonly root: Arrays.IHierarchicalItem<IFileExplorerNode>,
private readonly explorer: Explorer
parent: ExplorerNode,
public readonly explorer: Explorer
) { ) {
super(GitUri.fromRepoPath(repoPath));
super(GitUri.fromRepoPath(repoPath), parent);
} }
async getChildren(): Promise<(FolderNode | IFileExplorerNode)[]> { async getChildren(): Promise<(FolderNode | IFileExplorerNode)[]> {
@ -42,7 +43,7 @@ export class FolderNode extends ExplorerNode {
for (const folder of Objects.values(this.root.children)) { for (const folder of Objects.values(this.root.children)) {
if (folder.value === undefined) { if (folder.value === undefined) {
children.push( children.push(
new FolderNode(this.repoPath, folder.name, folder.relativePath, folder, this.explorer)
new FolderNode(this.repoPath, folder.name, folder.relativePath, folder, this, this.explorer)
); );
continue; continue;
} }

+ 9
- 4
src/views/nodes/lineHistoryNode.ts 查看文件

@ -20,9 +20,10 @@ export class LineHistoryNode extends SubscribeableExplorerNode
constructor( constructor(
uri: GitUri, uri: GitUri,
public readonly selection: Selection, public readonly selection: Selection,
parent: ExplorerNode,
explorer: LineHistoryExplorer explorer: LineHistoryExplorer
) { ) {
super(uri, explorer);
super(uri, parent, explorer);
} }
async getChildren(): Promise<ExplorerNode[]> { async getChildren(): Promise<ExplorerNode[]> {
@ -40,7 +41,7 @@ export class LineHistoryNode extends SubscribeableExplorerNode
children.push( children.push(
...Iterables.filterMap( ...Iterables.filterMap(
log.commits.values(), log.commits.values(),
c => new CommitFileNode(c.fileStatuses[0], c, this.explorer, displayAs, this.selection)
c => new CommitFileNode(c.fileStatuses[0], c, this, this.explorer, displayAs, this.selection)
) )
); );
} }
@ -75,11 +76,15 @@ export class LineHistoryNode extends SubscribeableExplorerNode
blame.commit.originalFileName || blame.commit.fileName blame.commit.originalFileName || blame.commit.fileName
); );
children.splice(0, 0, new CommitFileNode(status, commit, this.explorer, displayAs, this.selection));
children.splice(
0,
0,
new CommitFileNode(status, commit, this, this.explorer, displayAs, this.selection)
);
} }
} }
if (children.length === 0) return [new MessageNode('No line history')];
if (children.length === 0) return [new MessageNode(this, 'No line history')];
return children; return children;
} }

+ 3
- 3
src/views/nodes/lineHistoryTrackerNode.ts 查看文件

@ -15,7 +15,7 @@ export class LineHistoryTrackerNode extends SubscribeableExplorerNode
private _selection: Selection | undefined; private _selection: Selection | undefined;
constructor(explorer: LineHistoryExplorer) { constructor(explorer: LineHistoryExplorer) {
super(unknownGitUri, explorer);
super(unknownGitUri, undefined, explorer);
} }
dispose() { dispose() {
@ -34,10 +34,10 @@ export class LineHistoryTrackerNode extends SubscribeableExplorerNode
async getChildren(): Promise<ExplorerNode[]> { async getChildren(): Promise<ExplorerNode[]> {
if (this._child === undefined) { if (this._child === undefined) {
if (this.uri === unknownGitUri) { if (this.uri === unknownGitUri) {
return [new MessageNode('There are no editors open that can provide line history')];
return [new MessageNode(this, 'There are no editors open that can provide line history')];
} }
this._child = new LineHistoryNode(this.uri, this._selection!, this.explorer);
this._child = new LineHistoryNode(this.uri, this._selection!, this, this.explorer);
} }
return [this._child]; return [this._child];

+ 6
- 4
src/views/nodes/remoteNode.ts 查看文件

@ -14,10 +14,11 @@ export class RemoteNode extends ExplorerNode {
constructor( constructor(
public readonly remote: GitRemote, public readonly remote: GitRemote,
uri: GitUri, uri: GitUri,
private readonly repo: Repository,
private readonly explorer: GitExplorer
public readonly repo: Repository,
parent: ExplorerNode,
public readonly explorer: GitExplorer
) { ) {
super(uri);
super(uri, parent);
} }
get id(): string { get id(): string {
@ -37,7 +38,7 @@ export class RemoteNode extends ExplorerNode {
b => b =>
!b.remote || !b.name.startsWith(this.remote.name) !b.remote || !b.name.startsWith(this.remote.name)
? undefined ? undefined
: new BranchNode(b, this.uri, this.explorer)
: new BranchNode(b, this.uri, this, this.explorer)
) )
]; ];
if (this.explorer.config.branches.layout === ExplorerBranchesLayout.List) return branchNodes; if (this.explorer.config.branches.layout === ExplorerBranchesLayout.List) return branchNodes;
@ -55,6 +56,7 @@ export class RemoteNode extends ExplorerNode {
'', '',
undefined, undefined,
hierarchy, hierarchy,
this,
this.explorer this.explorer
); );
const children = (await root.getChildren()) as (BranchOrTagFolderNode | BranchNode)[]; const children = (await root.getChildren()) as (BranchOrTagFolderNode | BranchNode)[];

+ 6
- 5
src/views/nodes/remotesNode.ts 查看文件

@ -11,10 +11,11 @@ import { RemoteNode } from './remoteNode';
export class RemotesNode extends ExplorerNode { export class RemotesNode extends ExplorerNode {
constructor( constructor(
uri: GitUri, uri: GitUri,
private readonly repo: Repository,
private readonly explorer: GitExplorer
public readonly repo: Repository,
parent: ExplorerNode,
public readonly explorer: GitExplorer
) { ) {
super(uri);
super(uri, parent);
} }
get id(): string { get id(): string {
@ -23,10 +24,10 @@ export class RemotesNode extends ExplorerNode {
async getChildren(): Promise<ExplorerNode[]> { async getChildren(): Promise<ExplorerNode[]> {
const remotes = await this.repo.getRemotes(); const remotes = await this.repo.getRemotes();
if (remotes === undefined || remotes.length === 0) return [new MessageNode('No remotes configured')];
if (remotes === undefined || remotes.length === 0) return [new MessageNode(this, 'No remotes configured')];
remotes.sort((a, b) => a.name.localeCompare(b.name)); remotes.sort((a, b) => a.name.localeCompare(b.name));
return [...Iterables.map(remotes, r => new RemoteNode(r, this.uri, this.repo, this.explorer))];
return [...Iterables.map(remotes, r => new RemoteNode(r, this.uri, this.repo, this, this.explorer))];
} }
getTreeItem(): TreeItem { getTreeItem(): TreeItem {

+ 15
- 5
src/views/nodes/repositoriesNode.ts 查看文件

@ -13,7 +13,7 @@ export class RepositoriesNode extends SubscribeableExplorerNode {
private _children: (RepositoryNode | MessageNode)[] | undefined; private _children: (RepositoryNode | MessageNode)[] | undefined;
constructor(explorer: GitExplorer) { constructor(explorer: GitExplorer) {
super(unknownGitUri, explorer);
super(unknownGitUri, undefined, explorer);
} }
dispose() { dispose() {
@ -32,13 +32,13 @@ export class RepositoriesNode extends SubscribeableExplorerNode {
async getChildren(): Promise<ExplorerNode[]> { async getChildren(): Promise<ExplorerNode[]> {
if (this._children === undefined) { if (this._children === undefined) {
const repositories = [...(await Container.git.getRepositories())]; const repositories = [...(await Container.git.getRepositories())];
if (repositories.length === 0) return [new MessageNode('No repositories found')];
if (repositories.length === 0) return [new MessageNode(this, 'No repositories found')];
const children = []; const children = [];
for (const repo of repositories.sort((a, b) => a.index - b.index)) { for (const repo of repositories.sort((a, b) => a.index - b.index)) {
if (repo.closed) continue; if (repo.closed) continue;
children.push(new RepositoryNode(GitUri.fromRepoPath(repo.path), repo, this.explorer));
children.push(new RepositoryNode(GitUri.fromRepoPath(repo.path), repo, this, this.explorer));
} }
this._children = children; this._children = children;
@ -91,7 +91,7 @@ export class RepositoriesNode extends SubscribeableExplorerNode {
if (repositories.length === 0 && (this._children === undefined || this._children.length === 0)) return; if (repositories.length === 0 && (this._children === undefined || this._children.length === 0)) return;
if (repositories.length === 0) { if (repositories.length === 0) {
this._children = [new MessageNode('No repositories found')];
this._children = [new MessageNode(this, 'No repositories found')];
return; return;
} }
@ -104,7 +104,7 @@ export class RepositoriesNode extends SubscribeableExplorerNode {
child.refresh(); child.refresh();
} }
else { else {
children.push(new RepositoryNode(GitUri.fromRepoPath(repo.path), repo, this.explorer));
children.push(new RepositoryNode(GitUri.fromRepoPath(repo.path), repo, this, this.explorer));
} }
} }
@ -119,6 +119,8 @@ export class RepositoriesNode extends SubscribeableExplorerNode {
} }
protected async subscribe() { protected async subscribe() {
// TODO: Add a setting to control tracking the active editor
return Disposable.from( return Disposable.from(
window.onDidChangeActiveTextEditor(Functions.debounce(this.onActiveEditorChanged, 500), this), window.onDidChangeActiveTextEditor(Functions.debounce(this.onActiveEditorChanged, 500), this),
Container.git.onDidChangeRepositories(this.onRepositoriesChanged, this) Container.git.onDidChangeRepositories(this.onRepositoriesChanged, this)
@ -139,6 +141,14 @@ export class RepositoriesNode extends SubscribeableExplorerNode {
| undefined; | undefined;
if (node === undefined) return; if (node === undefined) return;
// Check to see if this repo has a descendent that is already selected
let parent = this.explorer.selection.length === 0 ? undefined : this.explorer.selection[0];
while (parent !== undefined) {
if (parent === node) return;
parent = parent.getParent();
}
// HACK: Since we have no expand/collapse api, reveal the first child to force an expand // HACK: Since we have no expand/collapse api, reveal the first child to force an expand
// See https://github.com/Microsoft/vscode/issues/55879 // See https://github.com/Microsoft/vscode/issues/55879
const children = await node.getChildren(); const children = await node.getChildren();

+ 11
- 10
src/views/nodes/repositoryNode.ts 查看文件

@ -34,9 +34,10 @@ export class RepositoryNode extends SubscribeableExplorerNode {
constructor( constructor(
uri: GitUri, uri: GitUri,
public readonly repo: Repository, public readonly repo: Repository,
parent: ExplorerNode,
explorer: GitExplorer explorer: GitExplorer
) { ) {
super(uri, explorer);
super(uri, parent, explorer);
this._status = this.repo.getStatus(); this._status = this.repo.getStatus();
} }
@ -61,29 +62,29 @@ export class RepositoryNode extends SubscribeableExplorerNode {
status.state.behind, status.state.behind,
status.detached status.detached
); );
children.push(new BranchNode(branch, this.uri, this.explorer, false));
children.push(new BranchNode(branch, this.uri, this, this.explorer, false));
if (status.state.behind) { if (status.state.behind) {
children.push(new StatusUpstreamNode(status, 'behind', this.explorer));
children.push(new StatusUpstreamNode(status, 'behind', this, this.explorer));
} }
if (status.state.ahead) { if (status.state.ahead) {
children.push(new StatusUpstreamNode(status, 'ahead', this.explorer));
children.push(new StatusUpstreamNode(status, 'ahead', this, this.explorer));
} }
if (status.state.ahead || (status.files.length !== 0 && this.includeWorkingTree)) { if (status.state.ahead || (status.files.length !== 0 && this.includeWorkingTree)) {
const range = status.upstream ? `${status.upstream}..${branch.ref}` : undefined; const range = status.upstream ? `${status.upstream}..${branch.ref}` : undefined;
children.push(new StatusFilesNode(status, range, this.explorer));
children.push(new StatusFilesNode(status, range, this, this.explorer));
} }
children.push(new MessageNode(GlyphChars.Dash.repeat(2), ''));
children.push(new MessageNode(this, GlyphChars.Dash.repeat(2), ''));
} }
children.push( children.push(
new BranchesNode(this.uri, this.repo, this.explorer),
new RemotesNode(this.uri, this.repo, this.explorer),
new StashesNode(this.uri, this.repo, this.explorer),
new TagsNode(this.uri, this.repo, this.explorer)
new BranchesNode(this.uri, this.repo, this, this.explorer),
new RemotesNode(this.uri, this.repo, this, this.explorer),
new StashesNode(this.uri, this.repo, this, this.explorer),
new TagsNode(this.uri, this.repo, this, this.explorer)
); );
this._children = children; this._children = children;
} }

+ 3
- 3
src/views/nodes/resultsCommitNode.ts 查看文件

@ -8,13 +8,13 @@ import { ExplorerNode, ResourceType } from './explorerNode';
export class ResultsCommitNode extends ExplorerNode { export class ResultsCommitNode extends ExplorerNode {
constructor( constructor(
public readonly commit: GitLogCommit, public readonly commit: GitLogCommit,
private readonly explorer: ResultsExplorer
public readonly explorer: ResultsExplorer
) { ) {
super(commit.toGitUri());
super(commit.toGitUri(), undefined);
} }
getChildren(): ExplorerNode[] { getChildren(): ExplorerNode[] {
return [new CommitNode(this.commit, this.explorer)];
return [new CommitNode(this.commit, this, this.explorer)];
} }
getTreeItem(): TreeItem { getTreeItem(): TreeItem {

+ 9
- 8
src/views/nodes/resultsCommitsNode.ts 查看文件

@ -18,11 +18,12 @@ export class ResultsCommitsNode extends ExplorerNode implements PageableExplorer
constructor( constructor(
public readonly repoPath: string, public readonly repoPath: string,
private readonly commitsQuery: (maxCount: number | undefined) => Promise<CommitsQueryResults>,
private readonly explorer: ResultsExplorer,
private readonly contextValue: ResourceType = ResourceType.ResultsCommits
private readonly _commitsQuery: (maxCount: number | undefined) => Promise<CommitsQueryResults>,
parent: ExplorerNode | undefined,
public readonly explorer: ResultsExplorer,
private readonly _contextValue: ResourceType = ResourceType.ResultsCommits
) { ) {
super(GitUri.fromRepoPath(repoPath));
super(GitUri.fromRepoPath(repoPath), parent);
} }
async getChildren(): Promise<ExplorerNode[]> { async getChildren(): Promise<ExplorerNode[]> {
@ -30,7 +31,7 @@ export class ResultsCommitsNode extends ExplorerNode implements PageableExplorer
if (log === undefined) return []; if (log === undefined) return [];
const children: (CommitNode | ShowAllNode)[] = [ const children: (CommitNode | ShowAllNode)[] = [
...Iterables.map(log.commits.values(), c => new CommitNode(c, this.explorer))
...Iterables.map(log.commits.values(), c => new CommitNode(c, this, this.explorer))
]; ];
if (log.truncated) { if (log.truncated) {
@ -47,20 +48,20 @@ export class ResultsCommitsNode extends ExplorerNode implements PageableExplorer
label, label,
log && log.count > 0 ? TreeItemCollapsibleState.Expanded : TreeItemCollapsibleState.None log && log.count > 0 ? TreeItemCollapsibleState.Expanded : TreeItemCollapsibleState.None
); );
item.contextValue = this.contextValue;
item.contextValue = this._contextValue;
return item; return item;
} }
async refresh() { async refresh() {
this._commitsQueryResults = this.commitsQuery(this.maxCount);
this._commitsQueryResults = this._commitsQuery(this.maxCount);
} }
private _commitsQueryResults: Promise<CommitsQueryResults> | undefined; private _commitsQueryResults: Promise<CommitsQueryResults> | undefined;
private getCommitsQueryResults() { private getCommitsQueryResults() {
if (this._commitsQueryResults === undefined) { if (this._commitsQueryResults === undefined) {
this._commitsQueryResults = this.commitsQuery(this.maxCount);
this._commitsQueryResults = this._commitsQuery(this.maxCount);
} }
return this._commitsQueryResults; return this._commitsQueryResults;

+ 4
- 4
src/views/nodes/resultsComparisonNode.ts 查看文件

@ -14,9 +14,9 @@ export class ResultsComparisonNode extends ExplorerNode {
public readonly repoPath: string, public readonly repoPath: string,
ref1: NamedRef, ref1: NamedRef,
ref2: NamedRef, ref2: NamedRef,
private readonly explorer: ResultsExplorer
public readonly explorer: ResultsExplorer
) { ) {
super(GitUri.fromRepoPath(repoPath));
super(GitUri.fromRepoPath(repoPath), undefined);
this._ref1 = ref1; this._ref1 = ref1;
this._ref2 = ref2; this._ref2 = ref2;
@ -34,8 +34,8 @@ export class ResultsComparisonNode extends ExplorerNode {
async getChildren(): Promise<ExplorerNode[]> { async getChildren(): Promise<ExplorerNode[]> {
return [ return [
new ResultsCommitsNode(this.uri.repoPath!, this.getCommitsQuery.bind(this), this.explorer),
new StatusFilesResultsNode(this.uri.repoPath!, this._ref1.ref, this._ref2.ref, this.explorer)
new ResultsCommitsNode(this.uri.repoPath!, this.getCommitsQuery.bind(this), this, this.explorer),
new StatusFilesResultsNode(this.uri.repoPath!, this._ref1.ref, this._ref2.ref, this, this.explorer)
]; ];
} }

+ 2
- 2
src/views/nodes/resultsNode.ts 查看文件

@ -10,11 +10,11 @@ export class ResultsNode extends ExplorerNode {
constructor( constructor(
public readonly explorer: ResultsExplorer public readonly explorer: ResultsExplorer
) { ) {
super(unknownGitUri);
super(unknownGitUri, undefined);
} }
async getChildren(): Promise<ExplorerNode[]> { async getChildren(): Promise<ExplorerNode[]> {
if (this._children.length === 0) return [new MessageNode('No results')];
if (this._children.length === 0) return [new MessageNode(this, 'No results')];
return this._children; return this._children;
} }

+ 3
- 3
src/views/nodes/stashFileNode.ts 查看文件

@ -2,11 +2,11 @@
import { GitLogCommit, IGitStatusFile } from '../../git/gitService'; import { GitLogCommit, IGitStatusFile } from '../../git/gitService';
import { Explorer } from '../explorer'; import { Explorer } from '../explorer';
import { CommitFileNode, CommitFileNodeDisplayAs } from './commitFileNode'; import { CommitFileNode, CommitFileNodeDisplayAs } from './commitFileNode';
import { ResourceType } from './explorerNode';
import { ExplorerNode, ResourceType } from './explorerNode';
export class StashFileNode extends CommitFileNode { export class StashFileNode extends CommitFileNode {
constructor(status: IGitStatusFile, commit: GitLogCommit, explorer: Explorer) {
super(status, commit, explorer, CommitFileNodeDisplayAs.File);
constructor(status: IGitStatusFile, commit: GitLogCommit, parent: ExplorerNode, explorer: Explorer) {
super(status, commit, parent, explorer, CommitFileNodeDisplayAs.File);
} }
protected get resourceType(): ResourceType { protected get resourceType(): ResourceType {

+ 4
- 3
src/views/nodes/stashNode.ts 查看文件

@ -10,9 +10,10 @@ import { StashFileNode } from './stashFileNode';
export class StashNode extends ExplorerRefNode { export class StashNode extends ExplorerRefNode {
constructor( constructor(
public readonly commit: GitStashCommit, public readonly commit: GitStashCommit,
private readonly explorer: Explorer
parent: ExplorerNode,
public readonly explorer: Explorer
) { ) {
super(commit.toGitUri());
super(commit.toGitUri(), parent);
} }
get id(): string { get id(): string {
@ -40,7 +41,7 @@ export class StashNode extends ExplorerRefNode {
} }
} }
const children = statuses.map(s => new StashFileNode(s, this.commit.toFileCommit(s), this.explorer));
const children = statuses.map(s => new StashFileNode(s, this.commit.toFileCommit(s), this, this.explorer));
children.sort((a, b) => a.label!.localeCompare(b.label!)); children.sort((a, b) => a.label!.localeCompare(b.label!));
return children; return children;
} }

+ 6
- 5
src/views/nodes/stashesNode.ts 查看文件

@ -11,10 +11,11 @@ import { StashNode } from './stashNode';
export class StashesNode extends ExplorerNode { export class StashesNode extends ExplorerNode {
constructor( constructor(
uri: GitUri, uri: GitUri,
private readonly repo: Repository,
private readonly explorer: Explorer
public readonly repo: Repository,
parent: ExplorerNode,
public readonly explorer: Explorer
) { ) {
super(uri);
super(uri, parent);
} }
get id(): string { get id(): string {
@ -23,9 +24,9 @@ export class StashesNode extends ExplorerNode {
async getChildren(): Promise<ExplorerNode[]> { async getChildren(): Promise<ExplorerNode[]> {
const stash = await this.repo.getStashList(); const stash = await this.repo.getStashList();
if (stash === undefined) return [new MessageNode('No stashed changes')];
if (stash === undefined) return [new MessageNode(this, 'No stashed changes')];
return [...Iterables.map(stash.commits.values(), c => new StashNode(c, this.explorer))];
return [...Iterables.map(stash.commits.values(), c => new StashNode(c, this, this.explorer))];
} }
getTreeItem(): TreeItem { getTreeItem(): TreeItem {

+ 4
- 2
src/views/nodes/statusFileCommitsNode.ts 查看文件

@ -22,9 +22,10 @@ export class StatusFileCommitsNode extends ExplorerNode {
public readonly repoPath: string, public readonly repoPath: string,
public readonly status: IGitStatusFile, public readonly status: IGitStatusFile,
public readonly commits: GitLogCommit[], public readonly commits: GitLogCommit[],
private readonly explorer: Explorer
parent: ExplorerNode,
public readonly explorer: Explorer
) { ) {
super(GitUri.fromFileStatus(status, repoPath, 'HEAD'));
super(GitUri.fromFileStatus(status, repoPath, 'HEAD'), parent);
} }
async getChildren(): Promise<ExplorerNode[]> { async getChildren(): Promise<ExplorerNode[]> {
@ -33,6 +34,7 @@ export class StatusFileCommitsNode extends ExplorerNode {
new CommitFileNode( new CommitFileNode(
this.status, this.status,
c, c,
this,
this.explorer, this.explorer,
CommitFileNodeDisplayAs.CommitLabel | CommitFileNodeDisplayAs.CommitLabel |
(this.explorer.config.avatars (this.explorer.config.avatars

+ 13
- 12
src/views/nodes/statusFileNode.ts 查看文件

@ -16,12 +16,13 @@ import { ExplorerNode, ResourceType } from './explorerNode';
export class StatusFileNode extends ExplorerNode { export class StatusFileNode extends ExplorerNode {
constructor( constructor(
public readonly repoPath: string, public readonly repoPath: string,
private readonly status: GitStatusFile,
private readonly ref1: string,
private readonly ref2: string,
private readonly explorer: Explorer
private readonly _status: GitStatusFile,
private readonly _ref1: string,
private readonly _ref2: string,
parent: ExplorerNode,
public readonly explorer: Explorer
) { ) {
super(GitUri.fromFileStatus(status, repoPath, ref1 ? ref1 : ref2 ? ref2 : undefined));
super(GitUri.fromFileStatus(_status, repoPath, _ref1 ? _ref1 : _ref2 ? _ref2 : undefined), parent);
} }
getChildren(): ExplorerNode[] { getChildren(): ExplorerNode[] {
@ -31,9 +32,9 @@ export class StatusFileNode extends ExplorerNode {
getTreeItem(): TreeItem { getTreeItem(): TreeItem {
const item = new TreeItem(this.label, TreeItemCollapsibleState.None); const item = new TreeItem(this.label, TreeItemCollapsibleState.None);
item.contextValue = ResourceType.StatusFile; item.contextValue = ResourceType.StatusFile;
item.tooltip = StatusFileFormatter.fromTemplate('${file}\n${directory}/\n\n${status}', this.status);
item.tooltip = StatusFileFormatter.fromTemplate('${file}\n${directory}/\n\n${status}', this._status);
const statusIcon = getGitStatusIcon(this.status.status);
const statusIcon = getGitStatusIcon(this._status.status);
item.iconPath = { item.iconPath = {
dark: Container.context.asAbsolutePath(path.join('images', 'dark', statusIcon)), dark: Container.context.asAbsolutePath(path.join('images', 'dark', statusIcon)),
light: Container.context.asAbsolutePath(path.join('images', 'light', statusIcon)) light: Container.context.asAbsolutePath(path.join('images', 'light', statusIcon))
@ -54,7 +55,7 @@ export class StatusFileNode extends ExplorerNode {
private _label: string | undefined; private _label: string | undefined;
get label() { get label() {
if (this._label === undefined) { if (this._label === undefined) {
this._label = StatusFileFormatter.fromTemplate(this.explorer.config.statusFileFormat, this.status, {
this._label = StatusFileFormatter.fromTemplate(this.explorer.config.statusFileFormat, this._status, {
relativePath: this.relativePath relativePath: this.relativePath
} as IStatusFormatOptions); } as IStatusFormatOptions);
} }
@ -82,14 +83,14 @@ export class StatusFileNode extends ExplorerNode {
this.uri, this.uri,
{ {
lhs: { lhs: {
sha: this.ref1,
sha: this._ref1,
uri: this.uri uri: this.uri
}, },
rhs: { rhs: {
sha: this.ref2,
sha: this._ref2,
uri: uri:
this.status.status === 'R'
? GitUri.fromFileStatus(this.status, this.uri.repoPath!, this.ref2, true)
this._status.status === 'R'
? GitUri.fromFileStatus(this._status, this.uri.repoPath!, this._ref2, true)
: this.uri : this.uri
}, },
repoPath: this.uri.repoPath!, repoPath: this.uri.repoPath!,

+ 5
- 3
src/views/nodes/statusFilesNode.ts 查看文件

@ -25,9 +25,10 @@ export class StatusFilesNode extends ExplorerNode {
constructor( constructor(
public readonly status: GitStatus, public readonly status: GitStatus,
public readonly range: string | undefined, public readonly range: string | undefined,
private readonly explorer: GitExplorer
parent: ExplorerNode,
public readonly explorer: GitExplorer
) { ) {
super(GitUri.fromRepoPath(status.repoPath));
super(GitUri.fromRepoPath(status.repoPath), parent);
this.repoPath = status.repoPath; this.repoPath = status.repoPath;
} }
@ -89,6 +90,7 @@ export class StatusFilesNode extends ExplorerNode {
repoPath, repoPath,
statuses[statuses.length - 1], statuses[statuses.length - 1],
statuses.map(s => s.commit), statuses.map(s => s.commit),
this,
this.explorer this.explorer
) )
) )
@ -102,7 +104,7 @@ export class StatusFilesNode extends ExplorerNode {
this.explorer.config.files.compact this.explorer.config.files.compact
); );
const root = new FolderNode(repoPath, '', undefined, hierarchy, this.explorer);
const root = new FolderNode(repoPath, '', undefined, hierarchy, this, this.explorer);
children = (await root.getChildren()) as IFileExplorerNode[]; children = (await root.getChildren()) as IFileExplorerNode[];
} }
else { else {

+ 11
- 7
src/views/nodes/statusFilesResultsNode.ts 查看文件

@ -17,11 +17,12 @@ export class StatusFilesResultsNode extends ExplorerNode {
constructor( constructor(
public readonly repoPath: string, public readonly repoPath: string,
private readonly ref1: string,
private readonly ref2: string,
private readonly explorer: Explorer
private readonly _ref1: string,
private readonly _ref2: string,
parent: ExplorerNode,
public readonly explorer: Explorer
) { ) {
super(GitUri.fromRepoPath(repoPath));
super(GitUri.fromRepoPath(repoPath), parent);
} }
async getChildren(): Promise<ExplorerNode[]> { async getChildren(): Promise<ExplorerNode[]> {
@ -29,7 +30,10 @@ export class StatusFilesResultsNode extends ExplorerNode {
if (diff === undefined) return []; if (diff === undefined) return [];
let children: IFileExplorerNode[] = [ let children: IFileExplorerNode[] = [
...Iterables.map(diff, s => new StatusFileNode(this.repoPath, s, this.ref1, this.ref2, this.explorer))
...Iterables.map(
diff,
s => new StatusFileNode(this.repoPath, s, this._ref1, this._ref2, this, this.explorer)
)
]; ];
if (this.explorer.config.files.layout !== ExplorerFilesLayout.List) { if (this.explorer.config.files.layout !== ExplorerFilesLayout.List) {
@ -40,7 +44,7 @@ export class StatusFilesResultsNode extends ExplorerNode {
this.explorer.config.files.compact this.explorer.config.files.compact
); );
const root = new FolderNode(this.repoPath, '', undefined, hierarchy, this.explorer);
const root = new FolderNode(this.repoPath, '', undefined, hierarchy, this, this.explorer);
children = (await root.getChildren()) as IFileExplorerNode[]; children = (await root.getChildren()) as IFileExplorerNode[];
} }
else { else {
@ -67,7 +71,7 @@ export class StatusFilesResultsNode extends ExplorerNode {
private async ensureCache() { private async ensureCache() {
if (this._cache === undefined) { if (this._cache === undefined) {
const diff = await Container.git.getDiffStatus(this.uri.repoPath!, this.ref1, this.ref2);
const diff = await Container.git.getDiffStatus(this.uri.repoPath!, this._ref1, this._ref2);
const count = diff !== undefined ? diff.length : 0; const count = diff !== undefined ? diff.length : 0;
const label = `${Strings.pluralize('file', count, { zero: 'No' })} changed`; const label = `${Strings.pluralize('file', count, { zero: 'No' })} changed`;

+ 5
- 4
src/views/nodes/statusUpstreamNode.ts 查看文件

@ -15,9 +15,10 @@ export class StatusUpstreamNode extends ExplorerNode implements PageableExplorer
constructor( constructor(
public readonly status: GitStatus, public readonly status: GitStatus,
public readonly direction: 'ahead' | 'behind', public readonly direction: 'ahead' | 'behind',
private readonly explorer: GitExplorer
parent: ExplorerNode,
public readonly explorer: GitExplorer
) { ) {
super(GitUri.fromRepoPath(status.repoPath));
super(GitUri.fromRepoPath(status.repoPath), parent);
} }
get id(): string { get id(): string {
@ -48,10 +49,10 @@ export class StatusUpstreamNode extends ExplorerNode implements PageableExplorer
} }
} }
children = commits.map(c => new CommitNode(c, this.explorer));
children = commits.map(c => new CommitNode(c, this, this.explorer));
} }
else { else {
children = [...Iterables.map(log.commits.values(), c => new CommitNode(c, this.explorer))];
children = [...Iterables.map(log.commits.values(), c => new CommitNode(c, this, this.explorer))];
} }
if (log.truncated) { if (log.truncated) {

+ 5
- 4
src/views/nodes/tagNode.ts 查看文件

@ -16,9 +16,10 @@ export class TagNode extends ExplorerRefNode implements PageableExplorerNode {
constructor( constructor(
public readonly tag: GitTag, public readonly tag: GitTag,
uri: GitUri, uri: GitUri,
private readonly explorer: GitExplorer
parent: ExplorerNode,
public readonly explorer: GitExplorer
) { ) {
super(uri);
super(uri, parent);
} }
get id(): string { get id(): string {
@ -40,10 +41,10 @@ export class TagNode extends ExplorerRefNode implements PageableExplorerNode {
maxCount: this.maxCount || this.explorer.config.defaultItemLimit, maxCount: this.maxCount || this.explorer.config.defaultItemLimit,
ref: this.tag.name ref: this.tag.name
}); });
if (log === undefined) return [new MessageNode('No commits yet')];
if (log === undefined) return [new MessageNode(this, 'No commits yet')];
const children: (CommitNode | ShowMoreNode)[] = [ const children: (CommitNode | ShowMoreNode)[] = [
...Iterables.map(log.commits.values(), c => new CommitNode(c, this.explorer))
...Iterables.map(log.commits.values(), c => new CommitNode(c, this, this.explorer))
]; ];
if (log.truncated) { if (log.truncated) {

+ 7
- 6
src/views/nodes/tagsNode.ts 查看文件

@ -13,10 +13,11 @@ import { TagNode } from './tagNode';
export class TagsNode extends ExplorerNode { export class TagsNode extends ExplorerNode {
constructor( constructor(
uri: GitUri, uri: GitUri,
private readonly repo: Repository,
private readonly explorer: GitExplorer
public readonly repo: Repository,
parent: ExplorerNode,
public readonly explorer: GitExplorer
) { ) {
super(uri);
super(uri, parent);
} }
get id(): string { get id(): string {
@ -25,10 +26,10 @@ export class TagsNode extends ExplorerNode {
async getChildren(): Promise<ExplorerNode[]> { async getChildren(): Promise<ExplorerNode[]> {
const tags = await this.repo.getTags(); const tags = await this.repo.getTags();
if (tags.length === 0) return [new MessageNode('No tags yet')];
if (tags.length === 0) return [new MessageNode(this, 'No tags yet')];
tags.sort((a, b) => a.name.localeCompare(b.name)); tags.sort((a, b) => a.name.localeCompare(b.name));
const tagNodes = [...tags.map(t => new TagNode(t, this.uri, this.explorer))];
const tagNodes = [...tags.map(t => new TagNode(t, this.uri, this, this.explorer))];
if (this.explorer.config.branches.layout === ExplorerBranchesLayout.List) return tagNodes; if (this.explorer.config.branches.layout === ExplorerBranchesLayout.List) return tagNodes;
const hierarchy = Arrays.makeHierarchical( const hierarchy = Arrays.makeHierarchical(
@ -38,7 +39,7 @@ export class TagsNode extends ExplorerNode {
this.explorer.config.files.compact this.explorer.config.files.compact
); );
const root = new BranchOrTagFolderNode('tag', this.repo.path, '', undefined, hierarchy, this.explorer);
const root = new BranchOrTagFolderNode('tag', this.repo.path, '', undefined, hierarchy, this, this.explorer);
const children = (await root.getChildren()) as (BranchOrTagFolderNode | TagNode)[]; const children = (await root.getChildren()) as (BranchOrTagFolderNode | TagNode)[];
return children; return children;
} }

+ 1
- 1
src/views/resultsExplorer.ts 查看文件

@ -180,7 +180,7 @@ export class ResultsExplorer extends ExplorerBase {
}; };
return this.addResults( return this.addResults(
new ResultsCommitsNode(results.repoPath, getCommitsQuery, this, ResourceType.SearchResults)
new ResultsCommitsNode(results.repoPath, getCommitsQuery, undefined, this, ResourceType.SearchResults)
); );
} }

Loading…
取消
儲存