fix: 实现 Agent 任务中私有 Gitea 仓库克隆的 Token 认证支持
This commit is contained in:
parent
9bfde8ec24
commit
d10f023a7e
|
|
@ -292,6 +292,7 @@ async def _execute_agent_task(task_id: str):
|
||||||
other_config = (user_config or {}).get('otherConfig', {})
|
other_config = (user_config or {}).get('otherConfig', {})
|
||||||
github_token = other_config.get('githubToken') or settings.GITHUB_TOKEN
|
github_token = other_config.get('githubToken') or settings.GITHUB_TOKEN
|
||||||
gitlab_token = other_config.get('gitlabToken') or settings.GITLAB_TOKEN
|
gitlab_token = other_config.get('gitlabToken') or settings.GITLAB_TOKEN
|
||||||
|
gitea_token = other_config.get('giteaToken') or settings.GITEA_TOKEN
|
||||||
|
|
||||||
# 获取项目根目录(传递任务指定的分支和认证 token)
|
# 获取项目根目录(传递任务指定的分支和认证 token)
|
||||||
# 🔥 传递 event_emitter 以发送克隆进度
|
# 🔥 传递 event_emitter 以发送克隆进度
|
||||||
|
|
@ -301,6 +302,7 @@ async def _execute_agent_task(task_id: str):
|
||||||
task.branch_name,
|
task.branch_name,
|
||||||
github_token=github_token,
|
github_token=github_token,
|
||||||
gitlab_token=gitlab_token,
|
gitlab_token=gitlab_token,
|
||||||
|
gitea_token=gitea_token, # 🔥 新增
|
||||||
event_emitter=event_emitter, # 🔥 新增
|
event_emitter=event_emitter, # 🔥 新增
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -2213,6 +2215,7 @@ async def _get_project_root(
|
||||||
branch_name: Optional[str] = None,
|
branch_name: Optional[str] = None,
|
||||||
github_token: Optional[str] = None,
|
github_token: Optional[str] = None,
|
||||||
gitlab_token: Optional[str] = None,
|
gitlab_token: Optional[str] = None,
|
||||||
|
gitea_token: Optional[str] = None, # 🔥 新增
|
||||||
event_emitter: Optional[Any] = None, # 🔥 新增:用于发送实时日志
|
event_emitter: Optional[Any] = None, # 🔥 新增:用于发送实时日志
|
||||||
) -> str:
|
) -> str:
|
||||||
"""
|
"""
|
||||||
|
|
@ -2228,6 +2231,7 @@ async def _get_project_root(
|
||||||
branch_name: 分支名称(仓库项目使用,优先于 project.default_branch)
|
branch_name: 分支名称(仓库项目使用,优先于 project.default_branch)
|
||||||
github_token: GitHub 访问令牌(用于私有仓库)
|
github_token: GitHub 访问令牌(用于私有仓库)
|
||||||
gitlab_token: GitLab 访问令牌(用于私有仓库)
|
gitlab_token: GitLab 访问令牌(用于私有仓库)
|
||||||
|
gitea_token: Gitea 访问令牌(用于私有仓库)
|
||||||
event_emitter: 事件发送器(用于发送实时日志)
|
event_emitter: 事件发送器(用于发送实时日志)
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
@ -2476,6 +2480,16 @@ async def _get_project_root(
|
||||||
parsed.fragment
|
parsed.fragment
|
||||||
))
|
))
|
||||||
await emit(f"🔐 使用 GitLab Token 认证")
|
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:
|
for branch in branches_to_try:
|
||||||
check_cancelled()
|
check_cancelled()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue