Skip to content

Commit 846f123

Browse files
committed
Fix listBranches: use pageInfo.hasNextPage instead of probe item to avoid first:101
1 parent fc4fd54 commit 846f123

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/VCS/Adapter/Git/GitHub.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ public function listBranches(string $owner, string $repositoryName, int $perPage
788788
'variables' => [
789789
'owner' => $owner,
790790
'name' => $repositoryName,
791-
'first' => $perPage + 1,
791+
'first' => $perPage,
792792
'after' => $cursor,
793793
'query' => $search !== '' ? $search : null,
794794
],
@@ -808,13 +808,13 @@ public function listBranches(string $owner, string $repositoryName, int $perPage
808808
}
809809

810810
$edges = $refs['edges'] ?? [];
811-
$hasNext = count($edges) > $perPage;
812-
$edges = array_slice($edges, 0, $perPage);
811+
$pageInfo = $refs['pageInfo'] ?? [];
812+
$hasNext = (bool) ($pageInfo['hasNextPage'] ?? false);
813813

814814
return [
815815
'items' => array_map(fn ($edge) => $edge['node']['name'] ?? '', $edges),
816816
'hasNext' => $hasNext,
817-
'nextCursor' => $hasNext ? ($edges[$perPage - 1]['cursor'] ?? null) : null,
817+
'nextCursor' => $hasNext ? ($pageInfo['endCursor'] ?? null) : null,
818818
];
819819
}
820820

0 commit comments

Comments
 (0)