feat(config): support multiple Gitea profiles via GITEA_PROFILE env var

未設時讀 config.env(行為不變);設了讀 config.<profile>.env。
.gitignore 新增 config.*.env 但保留 config.example.env。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
timmy
2026-04-21 16:18:16 +08:00
parent e333f7b8ab
commit f28f20ba56
6 changed files with 41 additions and 3 deletions

View File

@@ -35,7 +35,7 @@ bash /path/to/gitea-cli/scripts/list.sh [--private|--public] [--format table|tsv
所有 API / push / clone 都走 lib腳本本身不寫 curl 也不直接操作 credential helper。lib 提供:
- `load_config`:讀 `config.env`,檢查三個變數都非空非預設
- `load_config`:讀 `config.env`(或 `GITEA_PROFILE` 指定時讀 `config.<profile>.env`,檢查三個變數都非空非預設
- `gitea_api <METHOD> <path> [json-body]`:單一 API 呼叫入口;回傳後讀 `$HTTP_CODE``$GITEA_API_RESP_FILE`
- `git_push_with_token <branch>` / `git_push_tag_with_token <tag>` / `git_clone_with_token <clean-url> <target>`:一次性帶 token 的 git 操作
- `infer_repo_from_cwd`:從 `git remote get-url origin` 推斷 `owner/repo`