em->getRepository(Task::class)->find($uriVariables['taskId'] ?? 0); if (null === $task || null === $task->getProject()) { return []; } $project = $task->getProject(); if (!$project->hasGiteaRepo()) { return []; } $taskCode = $project->getCode().'-'.$task->getNumber(); try { $branches = $this->giteaApiService->listBranches($project, $taskCode); } catch (GiteaApiException) { return []; } $result = []; foreach ($branches as $branch) { $dto = new GiteaBranch(); $dto->name = $branch['name']; try { $commits = $this->giteaApiService->listBranchCommits($project, $branch['name']); $dto->commits = array_map(static fn (array $c): array => [ 'sha' => substr($c['sha'] ?? '', 0, 7), 'message' => $c['commit']['message'] ?? '', 'author' => $c['commit']['author']['name'] ?? '', 'date' => $c['commit']['author']['date'] ?? $c['created'] ?? '', ], $commits); } catch (GiteaApiException) { $dto->commits = []; } $result[] = $dto; } return $result; } }