|
|
@ -34,7 +34,6 @@ import { RemotesNode } from './nodes/remotesNode'; |
|
|
|
import { RepositoriesNode } from './nodes/repositoriesNode'; |
|
|
|
import { RepositoryNode } from './nodes/repositoryNode'; |
|
|
|
import { StashesNode } from './nodes/stashesNode'; |
|
|
|
import { StashNode } from './nodes/stashNode'; |
|
|
|
import { TagsNode } from './nodes/tagsNode'; |
|
|
|
import { WorktreeNode } from './nodes/worktreeNode'; |
|
|
|
import { WorktreesNode } from './nodes/worktreesNode'; |
|
|
@ -45,7 +44,7 @@ export class RepositoriesView extends ViewBase |
|
|
|
protected readonly configKey = 'repositories'; |
|
|
|
|
|
|
|
constructor(container: Container) { |
|
|
|
super(container, 'gitlens.views.repositories', 'Repositories', 'repositoriesView'); |
|
|
|
super(container, 'repositories', 'Repositories', 'repositoriesView'); |
|
|
|
} |
|
|
|
|
|
|
|
private _onDidChangeAutoRefresh = new EventEmitter<void>(); |
|
|
@ -276,10 +275,10 @@ export class RepositoriesView extends ViewBase |
|
|
|
} |
|
|
|
|
|
|
|
findBranch(branch: GitBranchReference, token?: CancellationToken) { |
|
|
|
const repoNodeId = RepositoryNode.getId(branch.repoPath); |
|
|
|
const { repoPath } = branch; |
|
|
|
|
|
|
|
if (branch.remote) { |
|
|
|
return this.findNode((n: any) => n.branch !== undefined && n.branch.ref === branch.ref, { |
|
|
|
return this.findNode((n: any) => n.branch?.ref === branch.ref, { |
|
|
|
allowPaging: true, |
|
|
|
maxDepth: 6, |
|
|
|
canTraverse: n => { |
|
|
@ -287,7 +286,7 @@ export class RepositoriesView extends ViewBase |
|
|
|
if (n instanceof RepositoriesNode) return true; |
|
|
|
|
|
|
|
if (n instanceof RemoteNode) { |
|
|
|
if (!n.id.startsWith(repoNodeId)) return false; |
|
|
|
if (n.repoPath !== repoPath) return false; |
|
|
|
|
|
|
|
return branch.remote && n.remote.name === getRemoteNameFromBranchName(branch.name); //branch.getRemoteName();
|
|
|
|
} |
|
|
@ -298,7 +297,7 @@ export class RepositoriesView extends ViewBase |
|
|
|
n instanceof RemotesNode || |
|
|
|
n instanceof BranchOrTagFolderNode |
|
|
|
) { |
|
|
|
return n.id.startsWith(repoNodeId); |
|
|
|
return n.repoPath === repoPath; |
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
@ -307,7 +306,7 @@ export class RepositoriesView extends ViewBase |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
return this.findNode((n: any) => n.branch !== undefined && n.branch.ref === branch.ref, { |
|
|
|
return this.findNode((n: any) => n.branch?.ref === branch.ref, { |
|
|
|
allowPaging: true, |
|
|
|
maxDepth: 5, |
|
|
|
canTraverse: n => { |
|
|
@ -315,7 +314,7 @@ export class RepositoriesView extends ViewBase |
|
|
|
if (n instanceof RepositoriesNode) return true; |
|
|
|
|
|
|
|
if (n instanceof RepositoryNode || n instanceof BranchesNode || n instanceof BranchOrTagFolderNode) { |
|
|
|
return n.id.startsWith(repoNodeId); |
|
|
|
return n.repoPath === repoPath; |
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
@ -325,7 +324,7 @@ export class RepositoriesView extends ViewBase |
|
|
|
} |
|
|
|
|
|
|
|
async findCommit(commit: GitCommit | { repoPath: string; ref: string }, token?: CancellationToken) { |
|
|
|
const repoNodeId = RepositoryNode.getId(commit.repoPath); |
|
|
|
const { repoPath } = commit; |
|
|
|
|
|
|
|
// Get all the branches the commit is on
|
|
|
|
let branches = await this.container.git.getCommitBranches( |
|
|
@ -334,26 +333,24 @@ export class RepositoriesView extends ViewBase |
|
|
|
isCommit(commit) ? { commitDate: commit.committer.date } : undefined, |
|
|
|
); |
|
|
|
if (branches.length !== 0) { |
|
|
|
return this.findNode((n: any) => n.commit !== undefined && n.commit.ref === commit.ref, { |
|
|
|
return this.findNode((n: any) => n.commit?.ref === commit.ref, { |
|
|
|
allowPaging: true, |
|
|
|
maxDepth: 6, |
|
|
|
canTraverse: async n => { |
|
|
|
// Only search for commit nodes in the same repo within BranchNodes
|
|
|
|
if (n instanceof RepositoriesNode) return true; |
|
|
|
|
|
|
|
if (n instanceof BranchNode) { |
|
|
|
if (n.id.startsWith(repoNodeId) && branches.includes(n.branch.name)) { |
|
|
|
await n.loadMore({ until: commit.ref }); |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if ( |
|
|
|
n instanceof RepositoryNode || |
|
|
|
n instanceof BranchesNode || |
|
|
|
n instanceof BranchOrTagFolderNode |
|
|
|
) { |
|
|
|
return n.id.startsWith(repoNodeId); |
|
|
|
return n.repoPath === repoPath; |
|
|
|
} |
|
|
|
|
|
|
|
if (n instanceof BranchNode && n.repoPath === repoPath && branches.includes(n.branch.name)) { |
|
|
|
await n.loadMore({ until: commit.ref }); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
@ -372,7 +369,7 @@ export class RepositoriesView extends ViewBase |
|
|
|
|
|
|
|
const remotes = branches.map(b => b.split('/', 1)[0]); |
|
|
|
|
|
|
|
return this.findNode((n: any) => n.commit !== undefined && n.commit.ref === commit.ref, { |
|
|
|
return this.findNode((n: any) => n.commit?.ref === commit.ref, { |
|
|
|
allowPaging: true, |
|
|
|
maxDepth: 8, |
|
|
|
canTraverse: n => { |
|
|
@ -380,15 +377,15 @@ export class RepositoriesView extends ViewBase |
|
|
|
if (n instanceof RepositoriesNode) return true; |
|
|
|
|
|
|
|
if (n instanceof RemoteNode) { |
|
|
|
return n.id.startsWith(repoNodeId) && remotes.includes(n.remote.name); |
|
|
|
return n.repoPath === repoPath && remotes.includes(n.remote.name); |
|
|
|
} |
|
|
|
|
|
|
|
if (n instanceof BranchNode) { |
|
|
|
return n.id.startsWith(repoNodeId) && branches.includes(n.branch.name); |
|
|
|
return n.repoPath === repoPath && branches.includes(n.branch.name); |
|
|
|
} |
|
|
|
|
|
|
|
if (n instanceof RepositoryNode || n instanceof RemotesNode || n instanceof BranchOrTagFolderNode) { |
|
|
|
return n.id.startsWith(repoNodeId); |
|
|
|
return n.repoPath === repoPath; |
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
@ -398,10 +395,14 @@ export class RepositoriesView extends ViewBase |
|
|
|
} |
|
|
|
|
|
|
|
findContributor(contributor: GitContributor, token?: CancellationToken) { |
|
|
|
const repoNodeId = RepositoryNode.getId(contributor.repoPath); |
|
|
|
const { repoPath, username, email, name } = contributor; |
|
|
|
|
|
|
|
return this.findNode( |
|
|
|
ContributorNode.getId(contributor.repoPath, contributor.name, contributor.email, contributor.username), |
|
|
|
n => |
|
|
|
n instanceof ContributorNode && |
|
|
|
n.contributor.username === username && |
|
|
|
n.contributor.email === email && |
|
|
|
n.contributor.name === name, |
|
|
|
{ |
|
|
|
maxDepth: 2, |
|
|
|
canTraverse: n => { |
|
|
@ -409,7 +410,7 @@ export class RepositoriesView extends ViewBase |
|
|
|
if (n instanceof RepositoriesNode) return true; |
|
|
|
|
|
|
|
if (n instanceof RepositoryNode || n instanceof ContributorsNode) { |
|
|
|
return n.id.startsWith(repoNodeId); |
|
|
|
return n.repoPath === repoPath; |
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
@ -420,7 +421,7 @@ export class RepositoriesView extends ViewBase |
|
|
|
} |
|
|
|
|
|
|
|
findRemote(remote: GitRemote, token?: CancellationToken) { |
|
|
|
const repoNodeId = RepositoryNode.getId(remote.repoPath); |
|
|
|
const { repoPath } = remote; |
|
|
|
|
|
|
|
return this.findNode((n: any) => n.remote?.name === remote.name, { |
|
|
|
allowPaging: true, |
|
|
@ -430,7 +431,7 @@ export class RepositoriesView extends ViewBase |
|
|
|
if (n instanceof RepositoriesNode) return true; |
|
|
|
|
|
|
|
if (n instanceof RepositoryNode || n instanceof RemotesNode) { |
|
|
|
return n.id.startsWith(repoNodeId); |
|
|
|
return n.repoPath === repoPath; |
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
@ -440,16 +441,16 @@ export class RepositoriesView extends ViewBase |
|
|
|
} |
|
|
|
|
|
|
|
findStash(stash: GitStashReference, token?: CancellationToken) { |
|
|
|
const repoNodeId = RepositoryNode.getId(stash.repoPath); |
|
|
|
const { repoPath } = stash; |
|
|
|
|
|
|
|
return this.findNode(StashNode.getId(stash.repoPath, stash.ref), { |
|
|
|
return this.findNode((n: any) => n.commit?.ref === stash.ref, { |
|
|
|
maxDepth: 3, |
|
|
|
canTraverse: n => { |
|
|
|
// Only search for stash nodes in the same repo within a StashesNode
|
|
|
|
if (n instanceof RepositoriesNode) return true; |
|
|
|
|
|
|
|
if (n instanceof RepositoryNode || n instanceof StashesNode) { |
|
|
|
return n.id.startsWith(repoNodeId); |
|
|
|
return n.repoPath === repoPath; |
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
@ -459,9 +460,9 @@ export class RepositoriesView extends ViewBase |
|
|
|
} |
|
|
|
|
|
|
|
findTag(tag: GitTagReference, token?: CancellationToken) { |
|
|
|
const repoNodeId = RepositoryNode.getId(tag.repoPath); |
|
|
|
const { repoPath } = tag; |
|
|
|
|
|
|
|
return this.findNode((n: any) => n.tag !== undefined && n.tag.ref === tag.ref, { |
|
|
|
return this.findNode((n: any) => n.tag?.ref === tag.ref, { |
|
|
|
allowPaging: true, |
|
|
|
maxDepth: 5, |
|
|
|
canTraverse: n => { |
|
|
@ -469,7 +470,7 @@ export class RepositoriesView extends ViewBase |
|
|
|
if (n instanceof RepositoriesNode) return true; |
|
|
|
|
|
|
|
if (n instanceof RepositoryNode || n instanceof TagsNode || n instanceof BranchOrTagFolderNode) { |
|
|
|
return n.id.startsWith(repoNodeId); |
|
|
|
return n.repoPath === repoPath; |
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
@ -479,16 +480,17 @@ export class RepositoriesView extends ViewBase |
|
|
|
} |
|
|
|
|
|
|
|
findWorktree(worktree: GitWorktree, token?: CancellationToken) { |
|
|
|
const repoNodeId = RepositoryNode.getId(worktree.repoPath); |
|
|
|
const { repoPath, uri } = worktree; |
|
|
|
const url = uri.toString(); |
|
|
|
|
|
|
|
return this.findNode(WorktreeNode.getId(worktree.repoPath, worktree.uri), { |
|
|
|
return this.findNode(n => n instanceof WorktreeNode && worktree.uri.toString() === url, { |
|
|
|
maxDepth: 2, |
|
|
|
canTraverse: n => { |
|
|
|
// Only search for worktree nodes in the same repo within WorktreesNode
|
|
|
|
if (n instanceof RepositoriesNode) return true; |
|
|
|
|
|
|
|
if (n instanceof RepositoryNode || n instanceof WorktreesNode) { |
|
|
|
return n.id.startsWith(repoNodeId); |
|
|
|
return n.repoPath === repoPath; |
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
@ -535,16 +537,14 @@ export class RepositoriesView extends ViewBase |
|
|
|
expand?: boolean | number; |
|
|
|
}, |
|
|
|
) { |
|
|
|
const repoNodeId = RepositoryNode.getId(repoPath); |
|
|
|
|
|
|
|
const node = await this.findNode(BranchesNode.getId(repoPath), { |
|
|
|
const node = await this.findNode(n => n instanceof BranchesNode && n.repoPath === repoPath, { |
|
|
|
maxDepth: 2, |
|
|
|
canTraverse: n => { |
|
|
|
// Only search for branches nodes in the same repo
|
|
|
|
if (n instanceof RepositoriesNode) return true; |
|
|
|
|
|
|
|
if (n instanceof RepositoryNode) { |
|
|
|
return n.id.startsWith(repoNodeId); |
|
|
|
return n.repoPath === repoPath; |
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
@ -648,9 +648,7 @@ export class RepositoriesView extends ViewBase |
|
|
|
expand?: boolean | number; |
|
|
|
}, |
|
|
|
) { |
|
|
|
const repoNodeId = RepositoryNode.getId(repoPath); |
|
|
|
|
|
|
|
const node = await this.findNode(repoNodeId, { |
|
|
|
const node = await this.findNode(n => n instanceof RepositoryNode && n.repoPath === repoPath, { |
|
|
|
maxDepth: 1, |
|
|
|
canTraverse: n => n instanceof RepositoriesNode, |
|
|
|
}); |
|
|
@ -700,16 +698,14 @@ export class RepositoriesView extends ViewBase |
|
|
|
expand?: boolean | number; |
|
|
|
}, |
|
|
|
) { |
|
|
|
const repoNodeId = RepositoryNode.getId(repoPath); |
|
|
|
|
|
|
|
const node = await this.findNode(StashesNode.getId(repoPath), { |
|
|
|
const node = await this.findNode(n => n instanceof StashesNode && n.repoPath === repoPath, { |
|
|
|
maxDepth: 2, |
|
|
|
canTraverse: n => { |
|
|
|
// Only search for stashes nodes in the same repo
|
|
|
|
if (n instanceof RepositoriesNode) return true; |
|
|
|
|
|
|
|
if (n instanceof RepositoryNode) { |
|
|
|
return n.id.startsWith(repoNodeId); |
|
|
|
return n.repoPath === repoPath; |
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
@ -761,16 +757,14 @@ export class RepositoriesView extends ViewBase |
|
|
|
expand?: boolean | number; |
|
|
|
}, |
|
|
|
) { |
|
|
|
const repoNodeId = RepositoryNode.getId(repoPath); |
|
|
|
|
|
|
|
const node = await this.findNode(TagsNode.getId(repoPath), { |
|
|
|
const node = await this.findNode(n => n instanceof TagsNode && n.repoPath === repoPath, { |
|
|
|
maxDepth: 2, |
|
|
|
canTraverse: n => { |
|
|
|
// Only search for tags nodes in the same repo
|
|
|
|
if (n instanceof RepositoriesNode) return true; |
|
|
|
|
|
|
|
if (n instanceof RepositoryNode) { |
|
|
|
return n.id.startsWith(repoNodeId); |
|
|
|
return n.repoPath === repoPath; |
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
@ -819,16 +813,14 @@ export class RepositoriesView extends ViewBase |
|
|
|
expand?: boolean | number; |
|
|
|
}, |
|
|
|
) { |
|
|
|
const repoNodeId = RepositoryNode.getId(repoPath); |
|
|
|
|
|
|
|
const node = await this.findNode(WorktreesNode.getId(repoPath), { |
|
|
|
const node = await this.findNode(n => n instanceof WorktreesNode && n.repoPath === repoPath, { |
|
|
|
maxDepth: 2, |
|
|
|
canTraverse: n => { |
|
|
|
// Only search for worktrees nodes in the same repo
|
|
|
|
if (n instanceof RepositoriesNode) return true; |
|
|
|
|
|
|
|
if (n instanceof RepositoryNode) { |
|
|
|
return n.id.startsWith(repoNodeId); |
|
|
|
return n.repoPath === repoPath; |
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|