Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions src/githubHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,31 @@ export class GithubHelper {
*/
async getAllGithubMilestones(): Promise<SimpleMilestone[]> {
try {
await utils.sleep(this.delayInMs);
// get an array of GitHub milestones for the new repo
let result = await this.githubApi.issues.listMilestones({
owner: this.githubOwner,
repo: this.githubRepo,
state: 'all',
});
let allMilestones: SimpleMilestone[] = [];
let page = 1;
const perPage = 100;

while (true) {
await utils.sleep(this.delayInMs);
const result = await this.githubApi.issues.listMilestones({
owner: this.githubOwner,
repo: this.githubRepo,
state: 'all',
per_page: perPage,
page,
});

if (result.data.length === 0) break;

allMilestones = allMilestones.concat(
result.data.map(x => ({ number: x.number, title: x.title })),
);

if (result.data.length < perPage) break;
page++;
}

return result.data.map(x => ({ number: x.number, title: x.title }));
return allMilestones;
} catch (err) {
console.error('Could not access all GitHub milestones');
console.error(err);
Expand Down