Skip to content

Commit c59e21d

Browse files
authored
Merge pull request #49 from utopia-php/ser-504
Return total & allow pagination in `searchRepositories`.
2 parents 1709b6c + 2d61d8f commit c59e21d

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/VCS/Adapter/Git/GitHub.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ public function searchRepositories(string $owner, int $page, int $per_page, stri
110110

111111
$response = $this->call(self::METHOD_GET, $url, ['Authorization' => "Bearer $this->accessToken"], [
112112
'q' => "{$search} user:{$owner} fork:true",
113+
'page' => $page,
113114
'per_page' => $per_page,
114115
'sort' => 'updated'
115116
]);
@@ -118,7 +119,10 @@ public function searchRepositories(string $owner, int $page, int $per_page, stri
118119
throw new Exception("Repositories list missing in the response.");
119120
}
120121

121-
return $response['body']['items'];
122+
return [
123+
'items' => $response['body']['items'],
124+
'total' => $response['body']['total_count'],
125+
];
122126
}
123127

124128
/**

tests/VCS/Base.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ public function testGetOwnerName(): void
5151

5252
public function testSearchRepositories(): void
5353
{
54-
$repos = $this->vcsAdapter->searchRepositories('test-kh', 1, 2);
54+
['items' => $repos, 'total' => $total] = $this->vcsAdapter->searchRepositories('test-kh', 1, 2);
5555
$this->assertCount(2, $repos);
56+
$this->assertSame(6, $total);
5657
}
5758

5859
public function testCreateComment(): void

0 commit comments

Comments
 (0)