em->getRepository(Task::class)->find($uriVariables['taskId'] ?? 0); if (null === $task || null === $task->getProject()) { throw new NotFoundHttpException('Task not found.'); } $project = $task->getProject(); if (!$project->hasGiteaRepo()) { throw new BadRequestHttpException('Project has no Gitea repository.'); } if (!in_array($data->type, self::ALLOWED_TYPES, true)) { throw new BadRequestHttpException('Invalid branch type.'); } try { $branchName = $this->giteaApiService->createBranch($project, $task, $data->type, $data->baseBranch); } catch (GiteaApiException $e) { throw new BadRequestHttpException($e->getMessage()); } $result = new GiteaBranch(); $result->name = $branchName; return $result; } }