feat: Add Gitea repository file fetching to the project file listing endpoint.
Build and Push CodeReview / build (push) Has been cancelled Details

This commit is contained in:
vinland100 2026-02-09 10:59:46 +08:00
parent a554503e04
commit a80ab66131
1 changed files with 6 additions and 1 deletions

View File

@ -19,7 +19,7 @@ from app.models.audit import AuditTask, AuditIssue
from app.models.agent_task import AgentTask, AgentTaskStatus, AgentFinding from app.models.agent_task import AgentTask, AgentTaskStatus, AgentFinding
from app.models.user_config import UserConfig from app.models.user_config import UserConfig
import zipfile import zipfile
from app.services.scanner import scan_repo_task, get_github_files, get_gitlab_files, get_github_branches, get_gitlab_branches, get_gitea_branches, should_exclude, is_text_file from app.services.scanner import scan_repo_task, get_github_files, get_gitlab_files, get_gitea_files, get_github_branches, get_gitlab_branches, get_gitea_branches, should_exclude, is_text_file
from app.services.zip_storage import ( from app.services.zip_storage import (
save_project_zip, load_project_zip, get_project_zip_meta, save_project_zip, load_project_zip, get_project_zip_meta,
delete_project_zip, has_project_zip delete_project_zip, has_project_zip
@ -451,6 +451,7 @@ async def get_project_files(
else: else:
# 使用API方式获取文件列表 # 使用API方式获取文件列表
repo_type = project.repository_type or "other" repo_type = project.repository_type or "other"
gitea_token = settings.GITEA_TOKEN
if repo_type == "github": if repo_type == "github":
# 传入用户自定义排除模式 # 传入用户自定义排除模式
@ -460,6 +461,10 @@ async def get_project_files(
# 传入用户自定义排除模式 # 传入用户自定义排除模式
repo_files = await get_gitlab_files(project.repository_url, target_branch, gitlab_token, parsed_exclude_patterns) repo_files = await get_gitlab_files(project.repository_url, target_branch, gitlab_token, parsed_exclude_patterns)
files = [{"path": f["path"], "size": 0} for f in repo_files] files = [{"path": f["path"], "size": 0} for f in repo_files]
elif repo_type == "gitea":
# 传入用户自定义排除模式
repo_files = await get_gitea_files(project.repository_url, target_branch, gitea_token, parsed_exclude_patterns)
files = [{"path": f["path"], "size": 0} for f in repo_files]
else: else:
raise HTTPException(status_code=400, detail="不支持的仓库类型") raise HTTPException(status_code=400, detail="不支持的仓库类型")
except HTTPException: except HTTPException: