From accc6ee32391ea96b1cc2539725f3b0c2fa18723 Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Thu, 14 May 2026 16:18:42 +0530 Subject: [PATCH] Limit VCS branch page fetches --- .../Repositories/Branches/XList.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/Branches/XList.php b/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/Branches/XList.php index 15661e499d..e8409af566 100644 --- a/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/Branches/XList.php +++ b/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/Branches/XList.php @@ -23,6 +23,9 @@ class XList extends Action { use HTTP; + private const GITHUB_BRANCHES_PER_PAGE = 100; + private const GITHUB_BRANCHES_MAX_PAGES = 10; + public static function getName() { return 'listRepositoryBranches'; @@ -149,14 +152,15 @@ class XList extends Action private function listBranches(GitHub $github, string $owner, string $repositoryName): array { $branches = []; - $page = 1; - $perPage = 100; - do { - $pageBranches = $github->listBranches($owner, $repositoryName, $perPage, $page); + for ($page = 1; $page <= self::GITHUB_BRANCHES_MAX_PAGES; $page++) { + $pageBranches = $github->listBranches($owner, $repositoryName, self::GITHUB_BRANCHES_PER_PAGE, $page); $branches = \array_merge($branches, $pageBranches); - $page++; - } while (\count($pageBranches) === $perPage); + + if (\count($pageBranches) < self::GITHUB_BRANCHES_PER_PAGE) { + break; + } + } return $branches; }