更新README.md,gitea仓库支持获取分支

This commit is contained in:
vinland100 2025-12-16 17:09:20 +08:00
parent 0fb10f6f76
commit 630b8b1a60
3 changed files with 32 additions and 10 deletions

View File

@ -63,7 +63,7 @@
<td width="50%" align="center">
<strong>🗂️ 项目管理</strong><br/><br/>
<img src="frontend/public/images/README-show/项目管理.png" alt="项目管理" width="95%"><br/>
<em>GitHub/GitLab 导入,多项目协同管理</em>
<em>GitHub/GitLab/Gitea 导入,多项目协同管理</em>
</td>
</tr>
</table>
@ -190,10 +190,22 @@ docker compose up -d
- PostgreSQL 14+
- Docker (用于沙箱)
### 1. 后端启动
### 1. 手动启动数据库
```bash
docker compose up -d redis db
```
### 2. 后端启动
```bash
cd backend
# 配置环境
cp env.example .env
# 激活虚拟环境 (推荐 uv/poetry)
source .venv/bin/activate
@ -204,15 +216,18 @@ pip install -r requirements.txt
uvicorn app.main:app --reload
```
### 2. 前端启动
### 3. 前端启动
```bash
cd frontend
# 配置环境
cp .env.example .env
npm install
npm run dev
```
### 3. 沙箱环境
### 4. 沙箱环境
开发模式下,仍需通过 Docker 启动沙箱服务。
```bash
@ -304,7 +319,7 @@ DeepSeek-Coder · Codestral<br/>
| 🤖 **Agent 深度审计** | Multi-Agent 协作,自主编排审计策略 | Agent |
| 🧠 **RAG 知识增强** | 代码语义理解CWE/CVE 知识库检索 | Agent |
| 🔒 **沙箱 PoC 验证** | Docker 隔离执行,验证漏洞有效性 | Agent |
| 🗂️ **项目管理** | GitHub/GitLab 导入ZIP 上传10+ 语言支持 | 通用 |
| 🗂️ **项目管理** | GitHub/GitLab/Gitea 导入ZIP 上传10+ 语言支持 | 通用 |
| ⚡ **即时分析** | 代码片段秒级分析,粘贴即用 | 通用 |
| 🔍 **五维检测** | Bug · 安全 · 性能 · 风格 · 可维护性 | 通用 |
| 💡 **What-Why-How** | 精准定位 + 原因解释 + 修复建议 | 通用 |

View File

@ -18,7 +18,7 @@ from app.models.user import User
from app.models.audit import AuditTask, AuditIssue
from app.models.user_config import UserConfig
import zipfile
from app.services.scanner import scan_repo_task, get_github_files, get_gitlab_files, get_github_branches, get_gitlab_branches, should_exclude, is_text_file
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.zip_storage import (
save_project_zip, load_project_zip, get_project_zip_meta,
delete_project_zip, has_project_zip
@ -659,9 +659,9 @@ async def get_project_branches(
config = config.scalar_one_or_none()
github_token = settings.GITHUB_TOKEN
gitlab_token = settings.GITLAB_TOKEN
SENSITIVE_OTHER_FIELDS = ['githubToken', 'gitlabToken']
projects_gitea_token = settings.GITEA_TOKEN
SENSITIVE_OTHER_FIELDS = ['githubToken', 'gitlabToken', 'giteaToken']
if config and config.other_config:
import json
@ -673,12 +673,14 @@ async def get_project_branches(
github_token = decrypted_val
elif field == 'gitlabToken':
gitlab_token = decrypted_val
elif field == 'giteaToken':
projects_gitea_token = decrypted_val
repo_type = project.repository_type or "other"
# 详细日志
print(f"[Branch] 项目: {project.name}, 类型: {repo_type}, URL: {project.repository_url}")
print(f"[Branch] GitHub Token: {'已配置' if github_token else '未配置'}, GitLab Token: {'已配置' if gitlab_token else '未配置'}")
print(f"[Branch] GitHub Token: {'已配置' if github_token else '未配置'}, GitLab Token: {'已配置' if gitlab_token else '未配置'}, Gitea Token: {'已配置' if projects_gitea_token else '未配置'}")
try:
if repo_type == "github":
@ -689,6 +691,10 @@ async def get_project_branches(
if not gitlab_token:
print("[Branch] 警告: GitLab Token 未配置,可能无法访问私有仓库")
branches = await get_gitlab_branches(project.repository_url, gitlab_token)
elif repo_type == "gitea":
if not projects_gitea_token:
print("[Branch] 警告: Gitea Token 未配置,可能无法访问私有仓库")
branches = await get_gitea_branches(project.repository_url, projects_gitea_token)
else:
# 对于其他类型,返回默认分支
print(f"[Branch] 仓库类型 '{repo_type}' 不支持获取分支,返回默认分支")

View File

@ -1018,6 +1018,7 @@ export default function Projects() {
<SelectContent className="bg-[#0c0c12] border-gray-700">
<SelectItem value="github">GITHUB</SelectItem>
<SelectItem value="gitlab">GITLAB</SelectItem>
<SelectItem value="gitea">GITEA</SelectItem>
<SelectItem value="other">OTHER</SelectItem>
</SelectContent>
</Select>