fix(gitea) : fetch only branch-specific commits using compare API

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-15 08:16:55 +01:00
parent f888a29e0a
commit 445f51b473
3 changed files with 17 additions and 12 deletions

View File

@@ -133,17 +133,21 @@ final readonly class GiteaApiService
/**
* @return array<array{sha: string, commit: array{message: string, author: array}, created: string}>
*/
public function listCommits(Project $project, string $branch): array
public function listBranchCommits(Project $project, string $branch): array
{
$this->assertProjectHasRepo($project);
return $this->request('GET', sprintf(
'/api/v1/repos/%s/%s/commits',
$defaultBranch = $this->getDefaultBranch($project);
$data = $this->request('GET', sprintf(
'/api/v1/repos/%s/%s/compare/%s...%s',
$project->getGiteaOwner(),
$project->getGiteaRepo(),
), [
'query' => ['sha' => $branch, 'limit' => 30],
]);
$defaultBranch,
urlencode($branch),
));
return $data['commits'] ?? [];
}
/**