Add server-side branch prefix search#110
Conversation
Uses GraphQL refs query with query variable for prefix filtering and cursor-based pagination instead of fetching all branches client-side.
Greptile SummaryThis PR migrates
Confidence Score: 3/5The test suite will fail as-is: the pre-existing page-2 pagination assertion was not updated to match the new cursor-less GraphQL implementation. The new listBranches implementation accepts $page in its signature but never forwards it to the GraphQL query. The testListBranchesPagination test still contains assertSame(['branch-b'], $page2) for a page-2 call, which will now return the first alphabetical branch instead of the second, causing a definite test failure on merge. tests/VCS/Adapter/GitHubTest.php lines 546-547 and the $page handling in src/VCS/Adapter/Git/GitHub.php Important Files Changed
|
| return array_values(array_map(fn ($branch) => $branch['name'] ?? '', $responseBody)); | ||
| $edges = $refs['edges'] ?? []; | ||
| $pageInfo = $refs['pageInfo'] ?? []; | ||
| $hasNext = (bool) ($pageInfo['hasNextPage'] ?? false); | ||
|
|
||
| return [ | ||
| 'items' => array_map(fn ($edge) => $edge['node']['name'] ?? '', $edges), | ||
| 'hasNext' => $hasNext, | ||
| 'nextCursor' => $hasNext ? ($pageInfo['endCursor'] ?? null) : null, | ||
| ]; |
There was a problem hiding this comment.
Keep old response structure - no hasNext, no cursor
| if ($page > 1) { | ||
| for ($i = 1; $i < $page; $i++) { |
| /** | ||
| * @return array{names: array<string>, endCursor: string|null} | ||
| */ | ||
| private function fetchBranchPage(string $owner, string $repositoryName, int $perPage, ?string $after, string $search): array |
Uses GraphQL refs query with query variable for prefix filtering and cursor-based pagination instead of fetching all branches client-side.