From d10f023a7eb61ab9461d4a800619263bc58d5cc6 Mon Sep 17 00:00:00 2001 From: vinland100 Date: Thu, 25 Dec 2025 15:26:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=9E=E7=8E=B0=20Agent=20=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E4=B8=AD=E7=A7=81=E6=9C=89=20Gitea=20=E4=BB=93?= =?UTF-8?q?=E5=BA=93=E5=85=8B=E9=9A=86=E7=9A=84=20Token=20=E8=AE=A4?= =?UTF-8?q?=E8=AF=81=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/api/v1/endpoints/agent_tasks.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/backend/app/api/v1/endpoints/agent_tasks.py b/backend/app/api/v1/endpoints/agent_tasks.py index f278513..126b67d 100644 --- a/backend/app/api/v1/endpoints/agent_tasks.py +++ b/backend/app/api/v1/endpoints/agent_tasks.py @@ -292,6 +292,7 @@ async def _execute_agent_task(task_id: str): other_config = (user_config or {}).get('otherConfig', {}) github_token = other_config.get('githubToken') or settings.GITHUB_TOKEN gitlab_token = other_config.get('gitlabToken') or settings.GITLAB_TOKEN + gitea_token = other_config.get('giteaToken') or settings.GITEA_TOKEN # 获取项目根目录(传递任务指定的分支和认证 token) # 🔥 传递 event_emitter 以发送克隆进度 @@ -301,6 +302,7 @@ async def _execute_agent_task(task_id: str): task.branch_name, github_token=github_token, gitlab_token=gitlab_token, + gitea_token=gitea_token, # 🔥 新增 event_emitter=event_emitter, # 🔥 新增 ) @@ -2213,6 +2215,7 @@ async def _get_project_root( branch_name: Optional[str] = None, github_token: Optional[str] = None, gitlab_token: Optional[str] = None, + gitea_token: Optional[str] = None, # 🔥 新增 event_emitter: Optional[Any] = None, # 🔥 新增:用于发送实时日志 ) -> str: """ @@ -2228,6 +2231,7 @@ async def _get_project_root( branch_name: 分支名称(仓库项目使用,优先于 project.default_branch) github_token: GitHub 访问令牌(用于私有仓库) gitlab_token: GitLab 访问令牌(用于私有仓库) + gitea_token: Gitea 访问令牌(用于私有仓库) event_emitter: 事件发送器(用于发送实时日志) Returns: @@ -2476,6 +2480,16 @@ async def _get_project_root( parsed.fragment )) await emit(f"🔐 使用 GitLab Token 认证") + elif repo_type == "gitea" and gitea_token: + auth_url = urlunparse(( + parsed.scheme, + f"{gitea_token}@{parsed.netloc}", + parsed.path, + parsed.params, + parsed.query, + parsed.fragment + )) + await emit(f"🔐 使用 Gitea Token 认证") for branch in branches_to_try: check_cancelled()