first commit

This commit is contained in:
Hermes Agent
2026-05-10 13:52:46 +08:00
commit ccc63d1e70
4583 changed files with 584341 additions and 0 deletions

View File

@@ -0,0 +1,77 @@
# Gitea 仓库盘点与枚举
## 枚举当前用户仓库(含私有)
```bash
TOKEN=$(grep -A1 'gitea.ephron.ren' ~/.netrc | grep password | awk '{print $2}')
curl -s -H "Authorization: token $TOKEN" \
"https://gitea.ephron.ren/api/v1/user/repos?limit=100&sort=updated" \
| jq '[.[] | {name: .full_name, private: .private, desc: (.description // ""), updated: .updated_at[:10]}]'
```
⚠️ **注意**: `/api/v1/repos/search` 默认不返回私有仓库。盘点仓库必须用 `/api/v1/user/repos`(当前用户)或 `/api/v1/users/{username}/repos`(指定用户)。
## 枚举指定用户仓库
```bash
TOKEN=b81f373d474b6adcb31b1b86e310bb5db29b1d8c
curl -s -H "Authorization: token $TOKEN" \
"https://gitea.ephron.ren/api/v1/users/{username}/repos?limit=100" \
| jq '[.[] | {name: .full_name, private: .private, desc: (.description // ""), updated: .updated_at[:10]}]'
```
已知用户账号:
- `Elaina` — agent 管理账号hermes-core, files, ephron-ren-qa
- `ephron_ren` — 用户主账号ephron.ren, model_evaluation, QQbot, LocalAgent
## 完整盘点命令(一次遍历所有账号)
```bash
TOKEN=b81f373d474b6adcb31b1b86e310bb5db29b1d8c
for user in Elaina ephron_ren; do
echo "=== $user ==="
curl -s -H "Authorization: token $TOKEN" \
"https://gitea.ephron.ren/api/v1/users/$user/repos?limit=100" \
| jq -r '.[] | "\(.full_name) | \(.private | if . then "🔒私有" else "🌐公开" end) | \(.description // "-") | \(.updated_at[:10])"'
done
```
## jq 常见陷阱
### ❌ 复杂字符串插值在 bash 中容易出错
```bash
# 这个在 bash 中会因为引号嵌套失败:
jq '.data[] | "\(.full_name) | \(.private ? "私有" : "公开")"'
```
### ✅ 正确做法:用对象提取 + 外部格式化
```bash
jq '[.[] | {name: .full_name, private: .private, desc: (.description // ""), updated: .updated_at[:10]}]'
```
或者用 `-r` + 简单插值:
```bash
jq -r '.[] | "\(.full_name) | \(.private) | \(.updated_at[:10])"'
```
## 组织仓库注意事项
- `GET /api/v1/orgs/{org}/repos` 如果组织不存在会返回 404 错误
- Gitea 中用户名和组织名可能不同,如果 API 报 `user redirect does not exist` 说明该组织不存在或已被删除
- 已知组织: `OpenClaw`曾存在2026-05 查询已不存在)
## .netrc Token 解析坑
### 常见问题
```bash
# ❌ 如果 ~/.netrc 格式异常grep -A1 可能取到错误行
TOKEN=$(grep -A1 'gitea.ephron.ren' ~/.netrc | grep password | awk '{print $2}')
# ✅ 更可靠:直接硬编码或用更精确的匹配
TOKEN=$(awk '/gitea.ephron.ren/{found=1} found && /password/{print $2; exit}' ~/.netrc)
```
### Token 格式
- Gitea API token 是一个长 hex 字符串(如 `b81f373d474b6adcb31b1b86e310bb5db29b1d8c`
- login 和 password 字段存储相同的 token 值
- 两种认证方式都可以: `-u "token:$TOKEN"``-H "Authorization: token $TOKEN"`