Skip to content

Commit ee8d380

Browse files
committed
Use installation/repositories API for searching repos
1 parent 9a58b9e commit ee8d380

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/VCS/Adapter/Git/GitHub.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,22 +106,22 @@ public function createRepository(string $owner, string $repositoryName, bool $pr
106106
*/
107107
public function searchRepositories(string $owner, int $page, int $per_page, string $search = ''): array
108108
{
109-
$url = '/search/repositories';
109+
$url = '/installation/repositories';
110110

111111
$response = $this->call(self::METHOD_GET, $url, ['Authorization' => "Bearer $this->accessToken"], [
112-
'q' => "{$search} user:{$owner} fork:true",
113112
'page' => $page,
114113
'per_page' => $per_page,
115-
'sort' => 'updated'
116114
]);
117115

118-
if (!isset($response['body']['items'])) {
116+
if (!isset($response['body']['repositories'])) {
119117
throw new Exception("Repositories list missing in the response.");
120118
}
121119

120+
$repositories = array_filter($response['body']['repositories'] ?? [], fn ($repo) => str_contains($repo['name'], $search));
121+
122122
return [
123-
'items' => $response['body']['items'],
124-
'total' => $response['body']['total_count'],
123+
'items' => $repositories,
124+
'total' => \count($repositories),
125125
];
126126
}
127127

0 commit comments

Comments
 (0)