Loading...
Loading...
Compare original and translation side by side
$GITEA_URL/api/v1/...$GITEA_TOKENcurl$GITEA_URL/api/v1/...$GITEA_TOKENcurlgit remote get-url origingithub.comghhttps://<host>curl -fsS --max-time 5 "https://<host>/api/v1/version"version$GITEA_URL$GITEA_TOKENGITEA_<ALIAS>_URLGITEA_<ALIAS>_TOKENGITEA_ORGA_URLGITEA_ORGA_TOKENgitea_autooriginGITEA_URLGITEA_TOKENGITEA_HOSTGITEA_ACCESS_TOKEN$GITEA_URL/apiAuthorization: token $GITEA_TOKEN?token=curl -sjq-o /dev/null -w '%{http_code}\n'--fail-with-body{ "message": "...", "url": "..." }DELETE/branches/contents/releases/tags?page=N&limit=Mpage=1limit=30per_page=Link: rel="next"PUT /repos/{owner}/{repo}/contents/{path}contentshasha{ success, data }{ "message": "...", "url": "..." }git remote get-url origingithub.comghhttps://<host>curl -fsS --max-time 5 "https://<host>/api/v1/version"version$GITEA_URL$GITEA_TOKENGITEA_<ALIAS>_URLGITEA_<ALIAS>_TOKENGITEA_ORGA_URLGITEA_ORGA_TOKENgitea_autooriginGITEA_URLGITEA_TOKENGITEA_HOSTGITEA_ACCESS_TOKEN$GITEA_URL/apiAuthorization: token $GITEA_TOKEN?token=curl -sjq-o /dev/null -w '%{http_code}\n'--fail-with-body{ "message": "...", "url": "..." }/branches/contents/releases/tagsDELETE?page=N&limit=Mpage=1limit=30per_page=Link: rel="next"PUT /repos/{owner}/{repo}/contents/{path}contentshasha{ success, data }{ "message": "...", "url": "..." }GITEA_<ALIAS>_URLGITEA_<ALIAS>_TOKENgitea_autoorigin$GITEA_URL$GITEA_TOKENundefinedGITEA_<ALIAS>_URLGITEA_<ALIAS>_TOKENgitea_autoorigin$GITEA_URL$GITEA_TOKENundefined
Two usage patterns:
- **Inside a repo**, no env set: `gitea_auto` parses `origin` and finds the alias whose `GITEA_<ALIAS>_URL` host matches.
- **Outside a repo, or targeting a different instance**: `export GITEA_URL=https://git.aaa.com` first, then `gitea_auto` will match `git.aaa.com` against the configured aliases and pull the right token. No need to remember which alias corresponds to which host.
Hard override: `gitea_use ORGA` activates the `ORGA` pair regardless of URL.
两种使用模式:
- **在仓库内**,未设置环境变量:`gitea_auto`解析`origin`并找到`GITEA_<ALIAS>_URL`主机匹配的别名。
- **在仓库外,或针对不同实例**:先执行`export GITEA_URL=https://git.aaa.com`,然后`gitea_auto`会将`git.aaa.com`与配置的别名匹配并获取正确的令牌。无需记住哪个别名对应哪个主机。
强制覆盖:`gitea_use ORGA`会激活`ORGA`对应的变量对,无论URL如何。giteagiteagiteaapi-*.mdgitea GET /version # health
gitea GET /user # token identity
gitea GET '/repos/foo/bar/issues?state=closed&limit=50' # list with query
gitea POST /repos/foo/bar/issues -d '{"title":"x"}' # write
gitea DELETE /repos/foo/bar/releases/42 # destructive$GITEA_URL/api/v1Content-Type: application/json{message, url}jqgiteaapi-*.mdgitea GET /version # 健康检查
gitea GET /user # 令牌身份验证
gitea GET '/repos/foo/bar/issues?state=closed&limit=50' # 带查询参数的列表查询
gitea POST /repos/foo/bar/issues -d '{"title":"x"}' # 写入操作
gitea DELETE /repos/foo/bar/releases/42 # 破坏性操作$GITEA_URL/api/v1Content-Type: application/json{message, url}jqISSUE=$(gitea POST /repos/{owner}/{repo}/issues \
-d '{"title":"fix auth bug","body":"Steps to reproduce..."}') || return 1
NUM=$(echo "$ISSUE" | jq -r '.number')
gitea POST "/repos/{owner}/{repo}/issues/$NUM/comments" \
-d '{"body":"PR will land tomorrow"}'ISSUE=$(gitea POST /repos/{owner}/{repo}/issues \
-d '{"title":"fix auth bug","body":"Steps to reproduce..."}') || return 1
NUM=$(echo "$ISSUE" | jq -r '.number')
gitea POST "/repos/{owner}/{repo}/issues/$NUM/comments" \
-d '{"body":"PR will land tomorrow"}'references/setup.mdreferences/api-repo.mdreferences/api-issues-prs.mdlist/get/create/update issueslist/get/diff/files/status/reviews/create/update/close/merge/update-branch/add-reviewersreferences/api-project.mdreferences/api-discovery.md/user/user/orgs/users/search/orgs/{org}/teams/search/repos/search/repos/issues/search/versionreferences/api-cicd.mdreferences/setup.mdreferences/api-repo.mdreferences/api-issues-prs.mdreferences/api-project.mdreferences/api-discovery.md/user/user/orgs/users/search/orgs/{org}/teams/search/repos/search/repos/issues/search/versionreferences/api-cicd.mdreferences/setup.mdreferences/api-repo.mdreferences/api-issues-prs.mdreferences/api-project.mdreferences/api-discovery.mdreferences/api-cicd.mdreferences/setup.mdreferences/api-repo.mdreferences/api-issues-prs.mdreferences/api-project.mdreferences/api-discovery.mdreferences/api-cicd.mdgit remote get-url origingithub.comgh/api/v1/versiongit remote get-url origingithub.comgh/api/v1/version