mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-13 03:28:35 -05:00
Adds rudimentary "paging" to custom view branch history
This commit is contained in:
@@ -3,22 +3,27 @@ import { Iterables } from '../system';
|
||||
import { ExtensionContext, TreeItem, TreeItemCollapsibleState } from 'vscode';
|
||||
import { CommitNode } from './commitNode';
|
||||
import { GlyphChars } from '../constants';
|
||||
import { ExplorerNode, ResourceType } from './explorerNode';
|
||||
import { ExplorerNode, ResourceType, ShowAllCommitsNode } from './explorerNode';
|
||||
import { GitBranch, GitService, GitUri } from '../gitService';
|
||||
|
||||
export class BranchHistoryNode extends ExplorerNode {
|
||||
|
||||
readonly resourceType: ResourceType = 'gitlens:branch-history';
|
||||
|
||||
maxCount: number | undefined = undefined;
|
||||
|
||||
constructor(public readonly branch: GitBranch, uri: GitUri, private readonly template: string, protected readonly context: ExtensionContext, protected readonly git: GitService) {
|
||||
super(uri);
|
||||
}
|
||||
|
||||
async getChildren(): Promise<ExplorerNode[]> {
|
||||
const log = await this.git.getLogForRepo(this.uri.repoPath!, this.branch.name, 0);
|
||||
const log = await this.git.getLogForRepo(this.uri.repoPath!, this.branch.name, this.maxCount);
|
||||
if (log === undefined) return [];
|
||||
|
||||
return [...Iterables.map(log.commits.values(), c => new CommitNode(c, this.template, this.context, this.git))];
|
||||
const children = Iterables.map(log.commits.values(), c => new CommitNode(c, this.template, this.context, this.git));
|
||||
if (!log.truncated) return [...children];
|
||||
|
||||
return [...children, new ShowAllCommitsNode(this, this.context)];
|
||||
}
|
||||
|
||||
async getTreeItem(): Promise<TreeItem> {
|
||||
|
||||
Reference in New Issue
Block a user