Fix: GitHub branch pagination#98
Conversation
Greptile SummaryThis PR adds configurable pagination to
Confidence Score: 4/5Safe to merge after adding error handling to The src/VCS/Adapter/Git/GitHub.php — specifically the Important Files Changed
Reviews (8): Last reviewed commit: "fix: use assertEqualsCanonicalizing for ..." | Re-trigger Greptile |
…ation test - Implement createBranch using GitHub refs API - Add page parameter to listBranches for consistency with other methods - Rewrite testListBranchesFetchesMultiplePages to use a real created repository with actual branches instead of a hardcoded external repo
| $adapter = $this->vcsAdapter; | ||
|
|
||
| $page1 = $adapter->listBranches(static::$owner, $repositoryName, 1, 1); | ||
| $this->assertCount(1, $page1); |
| $this->vcsAdapter->createRepository(static::$owner, $repositoryName, false); | ||
|
|
||
| try { | ||
| $branches = $this->vcsAdapter->listBranches(static::$owner, $repositoryName); |
There was a problem hiding this comment.
If failing because of default branch, find a way to deleteBranch()
| { | ||
| throw new Exception("Not implemented"); | ||
| $latestCommit = $this->getLatestCommit($owner, $repositoryName, $oldBranchName); | ||
| $sha = $latestCommit['commitHash']; | ||
|
|
||
| $response = $this->call(self::METHOD_POST, "/repos/$owner/$repositoryName/git/refs", ['Authorization' => "Bearer $this->accessToken"], [ | ||
| 'ref' => "refs/heads/$newBranchName", | ||
| 'sha' => $sha, | ||
| ]); | ||
|
|
||
| return $response['body'] ?? []; |
There was a problem hiding this comment.
createBranch silently swallows API errors
The method doesn't inspect the HTTP status code before returning. If GitHub rejects the request (e.g., 422 "Reference already exists", 404 branch not found, 403 permission denied), $response['body'] contains an error object like {"message":"Reference already exists",...} and createBranch returns it as if it succeeded. By contrast, listBranches in this same PR correctly gates its output on $statusCode < 200 || $statusCode >= 300. Callers of createBranch have no way to distinguish a successful ref payload from an error payload without parsing the message key themselves.
No description provided.