docs: 记录发布到 gitea.4i.hk 的仓库地址与推送认证方式

远端仓库:https://gitea.4i.hk/hhhge/SimpleFarm(public,main)。

关键坑:非交互 shell 里必须 GCM_INTERACTIVE=always,否则 GCM 会因为「用户交互被禁用」
直接拒绝,git 报 could not read Username / Failed to authenticate user,看起来像认证配错了。

另记:tea 的 OAuth token 能建仓、能调 API、能加 SSH 公钥,但不能签发访问令牌
(POST /users/{u}/tokens 需要 basic auth)。
This commit is contained in:
snowy-yang committed 2026-09-19 13:33:48 +08:00
1 parent 450655bebf
commit a92c29ead2
2 files changed
+45

No files matched your search

+22
View File
@@ -139,6 +139,28 @@ TUI 是纯客户端,同时开放 HTTP + SSE 接口给 AI/脚本调用(服务
- 路径保持 `str`(不要为了 lint 而转 `Path`);`farm/__init__.py` 的惰性 `__all__` 导出是刻意设计。
- 改完代码的标准动作:`uv run ruff format . && uv run ruff check . && uv run pyright`
## 远端仓库与推送(gitea.4i.hk)
- 远端:**https://gitea.4i.hk/hhhge/SimpleFarm**(public,默认分支 `main`,owner `hhhge`),
本地 `origin` 已指向 `https://gitea.4i.hk/hhhge/SimpleFarm.git` 并设好 upstream。
- **推送认证走 GCM 的 generic provider**(`credential.https://gitea.4i.hk.provider=generic`
写在 `~/.gitconfig` 里)。关键:**非交互 shell 里必须带 `GCM_INTERACTIVE=always`**,
否则 GCM 直接 `Cannot prompt because user interactivity has been disabled`,
接着 git 报 `could not read Username / Failed to authenticate user`,看起来像认证配置坏了。
加上这个环境变量后 GCM 会静默用已有的 OAuth 凭据续期,不需要弹窗也不需要手输:
`GCM_INTERACTIVE=always git push -u origin main`
- `tea` CLI(0.16.0)已用 OAuth 登录该实例,配置在 `%LOCALAPPDATA%\tea\config.yml`
(token 存在系统 keyring,**不在配置文件里**)。可用来建仓与调 API:
`tea repos create --name X --login gitea.4i.hk`(**没有 `--public` 参数,默认就是公开**)、
`tea api <path> -l gitea.4i.hk [-X POST -d '<json>']`。
限制:**OAuth token 不能签发访问令牌**(`POST /users/{u}/tokens` 需要 basic auth,
会返回 401 `auth required`,这是 Gitea 防提权的设计);但**可以用它加 SSH 公钥**
(`POST /user/keys`),所以将来若要免密推送,加一把密钥是可行的。
- 本机 git 走 `http.proxy / https.proxy = http://127.0.0.1:7890`(写在 `~/.gitconfig`)。
- **沙箱怪癖**:`.git/refs/remotes/**` 里"新建目录"的写入跨命令调用会被丢弃,
于是 `git status -sb` 一直显示 `## main...origin/main [gone]`(远端其实好着呢)。
修法是**在同一个命令里**先 `mkdir -p .git/refs/remotes/origin` + 写入 ref 文件,
紧接着跑 `git status`——分开两条命令就又看不到。真实终端里直接 `git fetch` 即可。
## 相关文档
- 项目入口文档:`README.md`(接口表、SSE 协议、边界处理、设计取舍全在里面)
- 当天工作记录:`.workbuddy/memory/2026-09-19.md`