From b9d5b6d9f0a8dee82d35b743b1c833e332d08738 Mon Sep 17 00:00:00 2001 From: pigeon Date: Sat, 6 Jun 2026 11:35:12 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=9B=B4=E6=96=B0=20Gitea=20API=20?= =?UTF-8?q?=E6=96=87=E6=A1=A3=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=AE=8C=E6=95=B4?= =?UTF-8?q?=E7=9A=84=20Issue=20=E5=88=9B=E5=BB=BA=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E5=92=8C=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ai-skills/gitea-api.md | 76 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 66 insertions(+), 10 deletions(-) diff --git a/ai-skills/gitea-api.md b/ai-skills/gitea-api.md index c0d6e5c..ec2cebd 100644 --- a/ai-skills/gitea-api.md +++ b/ai-skills/gitea-api.md @@ -6,32 +6,79 @@ ~/.config/gitea/token ``` +## 创建 Issue(工单) + +**步骤 1**: 准备 JSON 文件(避免转义问题) + +```bash +cat > /tmp/issue.json << 'EOF' +{ + "title": "[API-REQ] 简要描述所需接口", + "body": "## 接口地址\n\nPUT /xxx/xxx\n\n## 功能描述\n\n描述需要什么功能\n\n## 期望行为\n\n1. ...\n2. ...\n\n## 当前问题\n\n- ...\n\n## 前端使用场景\n\n描述为什么需要这个接口\n\n## 优先级\n\n高/中/低" +} +EOF +``` + +**步骤 2**: 调用 Gitea API 创建 Issue + +```bash +TOKEN=$(cat ~/.config/gitea/token) +curl -s -X POST \ + -H "Authorization: token ${TOKEN}" \ + -H "Content-Type: application/json" \ + -d @/tmp/issue.json \ + "https://git.dev.vifo.cc/api/v1/repos/{owner}/{repo}/issues" +``` + +**示例**(提交到 rui-framework 仓库): + +```bash +TOKEN=$(cat ~/.config/gitea/token) +curl -s -X POST \ + -H "Authorization: token ${TOKEN}" \ + -H "Content-Type: application/json" \ + -d @/tmp/issue.json \ + "https://git.dev.vifo.cc/api/v1/repos/rui/rui-framework/issues" +``` + +**返回示例**: +```json +{ + "id": 7, + "number": 2, + "title": "[API-REQ] 用户编辑接口密码字段处理优化", + "html_url": "https://git.dev.vifo.cc/rui/rui-framework/issues/2", + "state": "open" +} +``` + ## 获取 Issue ```bash -curl -s -H "Authorization: token $(cat ~/.config/gitea/token)" \ +TOKEN=$(cat ~/.config/gitea/token) +curl -s -H "Authorization: token ${TOKEN}" \ "https://git.dev.vifo.cc/api/v1/repos/{owner}/{repo}/issues/{id}" ``` ## 回复 Issue 评论 ```bash +TOKEN=$(cat ~/.config/gitea/token) curl -s -X POST \ - -H "Authorization: token $(cat ~/.config/gitea/token)" \ + -H "Authorization: token ${TOKEN}" \ -H "Content-Type: application/json" \ - -d '{"body": "评论内容"}' \ + -d '{"body": "✅ 已完成\n\n完成内容..."}' \ "https://git.dev.vifo.cc/api/v1/repos/{owner}/{repo}/issues/{id}/comments" ``` -**注意**: JSON 内容需要转义换行符 - ## 常用端点 -| 操作 | 端点 | -|------|------| -| 获取 Issue | `GET /api/v1/repos/{owner}/{repo}/issues/{id}` | -| 创建评论 | `POST /api/v1/repos/{owner}/{repo}/issues/{id}/comments` | -| 获取仓库 | `GET /api/v1/repos/{owner}/{repo}` | +| 操作 | 方法 | 端点 | +|------|------|------| +| 创建 Issue | POST | `/api/v1/repos/{owner}/{repo}/issues` | +| 获取 Issue | GET | `/api/v1/repos/{owner}/{repo}/issues/{id}` | +| 创建评论 | POST | `/api/v1/repos/{owner}/{repo}/issues/{id}/comments` | +| 获取仓库 | GET | `/api/v1/repos/{owner}/{repo}` | ## Git 远程地址 @@ -40,3 +87,12 @@ gitea ssh://git@git.dev.vifo.cc:222/rui/{repo}.git ``` **推送命令**: `git push gitea main`(注意不是 origin) + +## 注意事项 + +1. **JSON 内容**: 建议使用文件方式(`-d @file.json`)避免转义问题 +2. **Labels**: 创建 Issue 时 labels 参数需要传入 ID 数组,不是字符串数组 +3. **返回字段**: `number` 是 Issue 编号,`id` 是内部 ID +4. **仓库映射**: + - rui-framework: `/system/*`, `/user/*` + - rui-cashier: `/cashier/*`