feat(gitea-provider): auto-paginate Gitea repository and organization listing; respect explicit page option and default perPage to 50
This commit is contained in:
@@ -18,13 +18,45 @@ export class GiteaProvider extends BaseProvider {
|
||||
}
|
||||
|
||||
async getProjects(opts?: IListOptions): Promise<interfaces.data.IProject[]> {
|
||||
const repos = await this.client.getRepos(opts);
|
||||
return repos.map((r) => this.mapProject(r));
|
||||
// If caller explicitly requests a specific page, respect it (no auto-pagination)
|
||||
if (opts?.page) {
|
||||
const repos = await this.client.getRepos(opts);
|
||||
return repos.map((r) => this.mapProject(r));
|
||||
}
|
||||
|
||||
const allRepos: plugins.giteaClient.IGiteaRepository[] = [];
|
||||
const perPage = opts?.perPage || 50;
|
||||
let page = 1;
|
||||
|
||||
while (true) {
|
||||
const repos = await this.client.getRepos({ ...opts, page, perPage });
|
||||
allRepos.push(...repos);
|
||||
if (repos.length < perPage) break;
|
||||
page++;
|
||||
}
|
||||
|
||||
return allRepos.map((r) => this.mapProject(r));
|
||||
}
|
||||
|
||||
async getGroups(opts?: IListOptions): Promise<interfaces.data.IGroup[]> {
|
||||
const orgs = await this.client.getOrgs(opts);
|
||||
return orgs.map((o) => this.mapGroup(o));
|
||||
// If caller explicitly requests a specific page, respect it (no auto-pagination)
|
||||
if (opts?.page) {
|
||||
const orgs = await this.client.getOrgs(opts);
|
||||
return orgs.map((o) => this.mapGroup(o));
|
||||
}
|
||||
|
||||
const allOrgs: plugins.giteaClient.IGiteaOrganization[] = [];
|
||||
const perPage = opts?.perPage || 50;
|
||||
let page = 1;
|
||||
|
||||
while (true) {
|
||||
const orgs = await this.client.getOrgs({ ...opts, page, perPage });
|
||||
allOrgs.push(...orgs);
|
||||
if (orgs.length < perPage) break;
|
||||
page++;
|
||||
}
|
||||
|
||||
return allOrgs.map((o) => this.mapGroup(o));
|
||||
}
|
||||
|
||||
// --- Project Secrets ---
|
||||
|
||||
Reference in New Issue
Block a user