simplify branch fetch

This commit is contained in:
harsh mahajan committed 2026-06-11 16:48:33 +05:30
1 parent 80242cb89e
commit ae75d1468f
1 file changed
+8 -22
@@ -26,29 +26,15 @@
branch = repo.defaultBranch ?? 'main';
const allBranches = [];
let offset = 0;
const limit = 100;
const { branches } = await sdk
.forProject(page.params.region, page.params.project)
.vcs.listRepositoryBranches({
installationId,
providerRepositoryId: repositoryId,
queries: [Query.limit(1000)]
});
while (true) {
const { branches, total } = await sdk
.forProject(page.params.region, page.params.project)
.vcs.listRepositoryBranches({
installationId,
providerRepositoryId: repositoryId,
queries: [Query.limit(limit), Query.offset(offset)]
});
allBranches.push(...branches);
if (allBranches.length >= total || branches.length < limit) {
break;
}
offset += limit;
}
return sortBranches(allBranches);
return sortBranches(branches);
}
</script>