Repository navigation
Description
Problem
Checked: release/v0.2.25 at e9973c7 (every cited line is the same at 132ecc5); Gitea 1.27.3's API (templates/swagger/v1_json.tmpl), docs and pre-receive hook (routers/private/hook_pre_receive.go:189-224: deletion and force-push of a protected branch are refused for every user, admins included); the tea README. All on 2026-10-03.
Owner directions (2026-10-03).
- Every git repository under
repos/gets multiple remotes. Gitea (feat(k8s): the homelab runs gitea under argo cd as a read-write internal forge, served in-cluster over http and to workstations at https://git.<domain> through the cloudflare tunnel, with its admin secret pushed from the keyring #1081) is the internal forge for iteration that "can happen without going out to github". - Gitea communicates inside the cluster over HTTP, and the devops-cli configuration uses the Cloudflare tunnel domain alias over HTTPS. The workstation reaches Gitea at
https://git.<domain>, through the Cloudflare tunnel, asai.gateway_urlreacheshttps://ai.<domain>/v1.
What devops repos does today.
- Clones.
clone-organdcloneput clones atrepos/<org>/<name>(src/devops_cli/commands/repos.py:119-142 and :234-290). Every clone has one remote,origin, on GitHub. - Listing.
iter_workspace_repos(src/devops_cli/git/operations.py:65-76) yields every repository two levels under the root. - Sync.
devops repos synccallsfetch_all, which already fetches every remote with prune (operations.py:202-209), thenpull_tracking. - Nothing knows Gitea. No setting, credential, remote or API client names it.
How git reaches GitHub in the devcontainer. It uses a URL-scoped credential helper: GIT_CONFIG_KEY_0/_1 in .devcontainer/devcontainer.json:47-55 and src/devops_cli/templates/devcontainer.json.j2:47-55 set an empty helper for https://github.com, then !gh auth git-credential. Gitea's URL names the homelab's domain. devcontainer.json is committed and must name no private host, so Gitea's helper cannot be written there.
How the workstation passes Cloudflare Access. The CLI sends no Access headers anywhere (no CF-Access-Client-Id or service token in src/). Its https://<name>.<domain> URLs pass Access through the homelab-public-ip-bypass policy that devops cloudflare access sync writes (src/devops_cli/cloudflare/client.py:693-788). #1081 keeps git.<domain> behind the same application, so git and the API need no extra header, and Gitea's token is the authentication. From any other address, Access answers with a redirect to its login page. The client must recognise that redirect, because otherwise it looks like a broken Gitea.
The tools on offer.
- No official Python client. Gitea's official SDK is in Go (code.gitea.io/sdk).
- tea doesn't cover it. The official CLI, tea (v0.16.0, 2026-09-10), has no branch-protection command. It keeps its token in plain text under
$XDG_CONFIG_HOME/tea, which breaks the rule that credentials live in the keyring. - What does fit. Gitea's REST API through httpx2 (already a dependency,
devops_cli.http.client), and GitPython (already a dependency) for remotes, fetch and push.
Which side owns which branches. Pull mirrors are read-only and push mirrors force-push everything, so neither keeps a writable Gitea in step with GitHub (#1081). The model with the fewest moving parts uses the workstation, which already holds both remotes and both credentials:
- GitHub owns each repository's default branch (
mainhere), tags, PRs, CI and releases. - Gitea owns every other branch: the iteration branches.
- GitHub → Gitea.
devops repos syncfast-forwards Gitea'smainfromorigin, never forcing. - Gitea → GitHub. An iteration branch is promoted by pushing it to
originand opening a PR withdevops pr create, as today. - No new component. Nothing in the cluster syncs, and Gitea's mirror feature stays off.
Outcome:
- After
devops repos gitea connectand onedevops repos remotes, every clone underrepos/has agitearemote athttps://git.<domain>/<owner>/<name>.git. - Its repository exists on Gitea, private, with
mainprotected against force-push and deletion. git push gitea <branch>andgit fetch giteawork over HTTPS without a prompt, using a token read from the keyring.devops repos syncfetches both remotes and carries GitHub'smainover to Gitea.
Acceptance criteria
In the gate.
-
No network, no cluster and no DNS. Gitea's API is an
httpx2.MockTransport. Git runs ontmp_pathrepositories: a working clone, plus bare repositories standing in fororiginandgitea, created with GitPython. -
Structural tuple assertions throughout. Together under 1 s, checked with
uv run pytest tests/test_repos.py tests/test_repos_gitea.py tests/test_git_operations.py --durations=0. -
Settings and credential.
gitea.url: anhttps://URL with no path, unset by default; on the homelab,https://git.<domain>. Validation refuses any other scheme, so the token is never sent in clear.gitea.token: a managed credential inSECRET_CONFIG_OPTIONS, keyringgitea_token, envDEVOPS_CLI_GITEA_TOKEN, throughOPTION_TO_ENV_VARandKEYRING_KEYS.gitea.username: the token's login, saved byconnect; the credential helper answers with it.gitea.github_branches: default["main"]. Each clone's GitHub default branch (refs/remotes/origin/HEAD, read with GitPython) is always added, so a repository whose default ismasterordevelopis covered too.gitea.extra_checkouts: checkouts outsiderepos/that carry agitearemote, default empty.remotes --pathadds to it, sosynccovers them as well.devops config set gitea.tokenprompts with hidden input (feat(k8s): devops-cli runs in the homelab cluster as Jobs, and every cluster Secret is pushed from the keyring, also by deploy-stack (devops k8s push-secrets, devops k8s run-job) #741).
-
API client.
src/devops_cli/gitea/client.pywraps onehttpx2.Clientmade bydevops_cli.http.client.- Requests.
base_urlisgitea.url+/api/v1, with headerAuthorization: token <token>. Paths are built from path segments, and no URL is parsed by hand. - TLS. Certificates are verified against the system store. Cloudflare's edge certificate is public, so no CA is configured.
- Redirects are not followed. A redirect to another host is Cloudflare Access refusing the request. It raises
GiteaAccessBlocked, which says the workstation's public address is not in the Access bypass policy and points to feat(k8s): the homelab runs gitea under argo cd as a read-write internal forge, served in-cluster over http and to workstations at https://git.<domain> through the cloudflare tunnel, with its admin secret pushed from the keyring #1081's guide in k8s/README.md. The guide gives the full command,devops cloudflare access sync --domain '*.<domain>'with the allowed emails and bypass addresses set. A bareaccess sync --bypass-ips <address>would update the apex application and rewrite its allow policy from the configured emails, so the message does not suggest it. A Cloudflare challenge page (HTTP 403 with Cloudflare'scf-mitigated: challengeheader) raises the same error with that cause. Neither is reported as a Gitea error. - Typed calls. One call per endpoint, each returning a pydantic model:
version(GET /version, 200) andcurrent_user(GET /user, 200);org(GET /orgs/{org}, 200 or 404) andcreate_org(POST /orgs,visibility: private, 201);repo(GET /repos/{o}/{r}, 200 or 404);create_repo:POST /orgs/{org}/repos, orPOST /user/reposwhen the owner is the token's own login. The body hasprivate: trueandauto_init: false, and 201 is expected;branch_protections(GET /repos/{o}/{r}/branch_protections, 200) andcreate_branch_protection(POST, 201).
- Status codes. Any other status raises
GiteaErrornaming the call, the repository and Gitea'smessage, with the token masked bymask_secrets. - Why the owner check. User and organisation names share one namespace in Gitea, so an organisation cannot have the same name as the user.
- Requests.
-
devops repos gitea connect [--url URL] [--context CTX]:- The URL.
--urlwhen given. Otherwise the Ingress host ofgitea-httpin namespacegitea, found with the discoverydevops k8s configure-urls --addressing fqdnuses (_discover_ingress_hostsand_find_service_ingress_url, src/devops_cli/commands/k8s/networking.py:626 and :683), ashttps://<host>. No host is written into the repository. - Validated before any request. The URL, from
--urlor discovery, passes the same validation asgitea.urlbefore the token is read. Anhttp://URL, or one with a path, exits 1 with no request made, soconnect --url http://…never sends the token in clear. - checks
versionand thencurrent_userwith the keyring token; - saves
gitea.urlandgitea.username; - when
gitea.urlchanged, says to rundevops repos remotesagain; - prints the URL, the login and the version.
- A missing token exits 1, naming
devops config set gitea.token. No Ingress for Gitea exits 1, naming--url.GiteaAccessBlockedexits 1 with its message.
- The URL.
-
devops repos remotes [--base-dir DIR] [--path PATH]... [--dry-run]. For each clone fromiter_workspace_repos, plus eachgitea.extra_checkoutsentry and each--path(which is added togitea.extra_checkouts, resolved, once):- Owner and name.
- For
repos/<org>/<name>, they are the directory names. - For a
--pathoutsiderepos/, they come fromgh repo view --json owner,namerun in that checkout. No remote URL is parsed by hand. repos/_standalone/*is skipped with a note.
- For
- Repository.
- Ensure the organisation exists (read first; create only on 404). When the owner is the token's login, there is no organisation to create.
- Ensure the repository exists (read first; create only on 404), with
default_branchset to the clone's GitHub default branch.
- Protection.
- For the GitHub default branch and each pattern in
gitea.github_brancheswith no rule yet, create one withrule_name: <pattern>,enable_push: true,enable_force_push: falseandpriorityin list order. - Gitea matches a rule name as a glob over the whole branch name (usage/access-control/protected-branches).
- A protected branch cannot be deleted, so deletion needs no separate setting.
- For the GitHub default branch and each pattern in
- Remote.
- The
gitearemote is created with GitPython (Repo.create_remote), or its URL is set when it differs. - The URL is
gitea.urljoined with<owner>/<name>.gitthroughhttpx2.URL, for examplehttps://git.<domain>/<owner>/<name>.git. It never contains the token. originand branch upstreams are untouched.
- The
- Credential helper, in the clone's own config (
Repo.config_writer()):credential.<gitea.url>.helper(for examplecredential.https://git.<domain>.helper) is set to an empty value, then to!devops repos gitea credential, in that order. The empty value drops inherited helpers, as the devcontainer does for GitHub.- The helper is called by name,
devops, which must be onPATH(the devcontainer'spostStartCommandalready relies on it). git runs helpers from the clone, whereuv runwould not find devops-cli's project. - When the remote's URL changes, the old URL's
credential.<old-url>.helperentries are removed, so no helper is left for an address Gitea no longer answers on. - Global git config is not touched.
- Two remotes stay unambiguous. In the clone's config:
checkout.defaultRemote = origin. Withmainon both remotes,git switch <branch>andgit worktree add <path> <branch>would otherwise fail with "matched multiple remote tracking branches" when no local branch exists.remote.gitea.tagOpt = --no-tags. Tags are GitHub's; Gitea's are never fetched into the clone.
- Seeding. The first run pushes
refs/remotes/origin/<b>:refs/heads/<b>for the GitHub default branch and every origin branch matchinggitea.github_branches. - Safe to repeat. A second run with nothing changed makes only GET calls and no push.
- Dry run.
--dry-runprints the plan per clone and makes only GET calls. - One table at the end. Columns: clone, created, protected, remote, seeded.
- Errors. A failed clone is reported and the rest continue. The exit code is 1 if any clone failed.
GiteaAccessBlockedstops the run at the first clone, since every later call would fail the same way.
- Owner and name.
-
devops repos gitea credential get|store|erase. A git credential helper (gitcredentials(7)), hidden from--help:getreads git'skey=valuelines from stdin. Whenprotocolishttpsandhost(with any port) matchesgitea.url, it printsusername=<gitea.username>and `password= from the keyring. It makes no network call.- For any other protocol or host it prints nothing, so git moves on.
storeanderasedo nothing. The keyring is changed only bydevops config set.- The token never reaches argv, a log or a file.
-
devops repos sync. It covers the clones underrepos/plusgitea.extra_checkouts. Afterfetch_all, which already fetchesgitea, it pushes for each one with agitearemote. Pushing is on by default and--no-giteaturns it off.- What it pushes.
refs/remotes/origin/<b>:refs/heads/<b>for the GitHub default branch and every origin branch matchinggitea.github_branches, without+, through GitPython'sRemote.push. - Matching. Branch names are matched with
PurePosixPath(branch).full_match(pattern), where*does not cross/, as in Gitea's glob. - Results. Read from
PushInfoflags, not from git's output:- up to date or fast-forwarded counts as success;
- a rejected non-fast-forward is reported per branch, naming
git log gitea/<b> ^origin/<b>to inspect and the person's fix. Nothing is forced; - the run continues to the next branch.
- Iteration branches are never pushed by sync.
- Fetch failures. A failed fetch from
originor fromgiteais reported, and that clone's Gitea push is skipped: a staleoriginref would be rejected as if Gitea had diverged. Todayfetch_allswallowsGitCommandErrorsilently (operations.py:206-209).
- What it pushes.
-
cloneandclone-org. Whengitea.urlis set, each new clone runs the same ensure step asremotes. A Gitea failure is a warning, and the clone stays. -
Tests. tests/test_repos_gitea.py covers:
- organisation and repository creation on 404, and no POST on 200;
- the user-namespace path when the owner equals the login;
- one protection per pattern, and none created twice;
- the remote added at the
https://URL, and its URL refreshed whengitea.urlchanges; - the two helper entries, in order, in the clone's config, and the old URL's entries removed when the URL changes;
checkout.defaultRemoteandremote.gitea.tagOptset;- a clone whose origin default branch is
master:masteris created as Gitea's default branch, protected, seeded and synced; --pathrecorded once ingitea.extra_checkouts, and sync covering that checkout;- the credential helper's output for a matching
httpshost, and nothing for anhttprequest to the same host or another host; the token in no argv (a recordingrun_subprocessstub); gitea.urlwithhttp://refused by validation, andconnect --url http://…exiting 1 with no request on theMockTransportand no keyring read;connectwith--url, and with the URL found from a stubbedkubectl get ingress -A -o json;- a 302 to another host and a 403 carrying
cf-mitigated: challenge, each raisingGiteaAccessBlockedwith the bypass hint and no token in the message; - sync fast-forwarding
maininto the baregitea; - sync reporting a diverged
mainas rejected and leaving it unchanged; - an unreachable
gitearemote, or a failedoriginfetch, reported with no push attempted; - an iteration branch never pushed;
--dry-runmaking no POST and no push;- the error path masking the token.
-
Docs.
- Help strings go in
lang/en/help.py. Regenerate docs/commands/repos.md and docs/CLI_REFERENCE.md withdevops docs generate, anddevops docs checkpasses. - A "Gitea remotes" section in docs/ (the page that documents
devops repos) gives:- the branch ownership rule;
- the one-time setup: create a token in Gitea's UI at
https://git.<domain>with scopeswrite:repository,write:organizationandread:user, thendevops config set gitea.token,devops repos gitea connectanddevops repos remotes; - that git and the API pass Cloudflare Access only from the bypassed address, and what the Access error means (link to feat(k8s): the homelab runs gitea under argo cd as a read-write internal forge, served in-cluster over http and to workstations at https://git.<domain> through the cloudflare tunnel, with its admin secret pushed from the keyring #1081's guide in k8s/README.md);
- the iteration flow:
git switch -c <topic> origin/main, thengit push -u gitea <topic>, and latergit push origin <topic>withdevops pr create.
- Help strings go in
-
devops pr check-readinesspasses. -
uv run devops cipasses within its 5-minute budget.
Checks a person runs (devcontainer, keyring unlocked, after #1081's checks pass):
- Pending a person, Connect:
uv run devops repos gitea connect --context <context>exits 0, printshttps://git.<domain>, the login and Gitea's version, anduv run devops config get gitea.urlprints the same URL. - Pending a person, Remotes:
uv run devops repos remotesexits 0.- Then, for every clone,
git -C repos/<org>/<name> remote -vlistsoriginandgiteaathttps://git.<domain>/<org>/<name>.git. - A second run prints no "created" row.
- Pending a person, Push without a prompt: in one clone,
GIT_TERMINAL_PROMPT=0 git push -u gitea HEAD:refs/heads/try/remote-checksucceeds, thengit push gitea --delete try/remote-check. - Pending a person, Largest clone seeded: the seed of the clone with the largest pack succeeds through the tunnel. Cloudflare caps a request body at 100 MB on the Free and Pro plans, and one push is one request. On 2026-10-03 the largest
.gitunderrepos/was about 17 MB and devops-cli's pack 15 MiB, so the cap is far off. A push over it fails with HTTP 413; pushing the history in steps avoids it. The edge also cuts a request whose reply takes more than about 125 s (the owner's finding of 2026-10-03 onai.<domain>, fix(ai): review calls through the gateway no longer stall for about 190 s on ollama, with the cause measured first #1069's path), so the seed'sgit pushmust finish well inside that. - Pending a person, Sync carries GitHub over: after a merge on GitHub,
uv run devops repos syncexits 0, andgit -C <clone> rev-parse origin/main gitea/mainprints the same commit twice. The same holds for/workspaces/devops-cli, once it was added with--path. - Pending a person, Unambiguous checkout: in
/workspaces/devops-cli,git worktree add /tmp/dwim-check <a branch on both remotes with no local branch>succeeds andgit -C /tmp/dwim-check rev-parse --abbrev-ref @{upstream}printsorigin/<branch>. Thengit worktree remove /tmp/dwim-checkandgit branch -d <branch>. - Pending a person, Protected:
git -C <clone> push --force gitea HEAD~1:mainis refused by Gitea's branch protection. - Pending a person, Token stays in the keyring:
grep -r -l "$(uv run keyring get devops-cli gitea_token)" repos/*/*/.git/config ~/.gitconfigprints nothing.git -C <clone> config --get-all credential.https://git.<domain>.helperprints the empty entry and the devops one.
Key questions
- Which side is authoritative for what? Proposed:
- GitHub:
main, tags, and everything that reviews, tests or ships them. - Gitea: every other branch.
- Why this split. It follows the existing flow: PRs target
mainon GitHub, CI runs there, and the release workflow publishes from there.
- GitHub:
- How do the two stay in step, with the fewest moving parts? Proposed: through
devops repos syncon the workstation.- A Gitea pull mirror refuses pushes. A Gitea push mirror force-pushes every ref and would erase GitHub's merges. An in-cluster sync job would be a new component with its own GitHub credential.
- The workstation already fetches both remotes and holds both credentials.
- The cost. Gitea's copy of
mainlags until someone syncs. Only people and agents at a workstation read it, and they sync first. Argo CD reads GitHub (feat(k8s): Point Argo CD to Gitea for git and PR dev images #1082).
- What if someone pushes to
mainon Gitea? Proposed: protection cannot tell an agent from the sync, because both use the owner's token. Instead:- force-push is refused;
- a plain push that diverges from GitHub makes the next sync report the branch as rejected;
- a person inspects it and resets Gitea's branch with
git push --force-with-lease=main gitea origin/main:mainafter lifting the rule, or moves the commits to an iteration branch. - A separate sync account with a push allowlist would block this, at the cost of a second token. Offered if it happens in practice.
- Why not a
devops repos pushwrapper? Proposed:git push gitea <branch>already does the job once the remote and helper exist. A wrapper would add a command without adding a check. - Which URL do the remotes use? Decided (owner, 2026-10-03): the tunnel alias over HTTPS,
https://git.<domain>. In-cluster HTTP (http://gitea-http.gitea.svc.cluster.local:3000) is for pods and Argo CD only (feat(k8s): the homelab runs gitea under argo cd as a read-write internal forge, served in-cluster over http and to workstations at https://git.<domain> through the cloudflare tunnel, with its admin secret pushed from the keyring #1081, feat(k8s): Point Argo CD to Gitea for git and PR dev images #1082). - How does git authenticate? Proposed:
- The helper. devops-cli acts as a URL-scoped git credential helper for
https://git.<domain>that reads the keyring token. It is the same shape asgh auth git-credentialfor GitHub. - Cloudflare Access. Git sends no Access header. The workstation passes Access through the public-IP bypass, and Gitea's token is the authentication (feat(k8s): the homelab runs gitea under argo cd as a read-write internal forge, served in-cluster over http and to workstations at https://git.<domain> through the cloudflare tunnel, with its admin secret pushed from the keyring #1081). A credential helper could not add Access headers anyway: it returns only a username and password.
- Rejected alternatives. The token in the remote URL, or in
http.extraHeader, puts it on disk. tea's helper keeps the token in plain text.git-credential-libsecretkeeps a second copy under other keyring attributes. - Where it is configured. In each clone's config, because the URL names the homelab's domain and devcontainer.json is committed.
- The helper. devops-cli acts as a URL-scoped git credential helper for
- HTTPS or SSH? Proposed: HTTPS. SSH is off in Gitea (feat(k8s): the homelab runs gitea under argo cd as a read-write internal forge, served in-cluster over http and to workstations at https://git.<domain> through the cloudflare tunnel, with its admin secret pushed from the keyring #1081), and through the tunnel it would need
cloudflared access sshon every client. - Where do owner and name come from? Proposed: from the directory layout
devops reposalready enforces (repos/<org>/<name>), and fromgh repo viewfor a checkout outsiderepos/. Neither parses a URL by hand. - Should the main
/workspaces/devops-clicheckout get the remote too? Proposed: yes, withdevops repos remotes --path /workspaces/devops-cli. The path is recorded ingitea.extra_checkouts, sodevops repos synckeeps that checkout's Giteamainin step too; without it, they would stay at the first seed.- Agents iterate on devops-cli in worktrees of that checkout, and worktrees share its remotes.
- feat(k8s): Point Argo CD to Gitea for git and PR dev images #1082's trials deploy devops-cli branches from Gitea.
- Owner decision.
- Which token scopes? Proposed:
write:repository(push, create repositories, branch protection),write:organization(create organisations), andread:user(GET /user). The owner creates the token in Gitea's UI once, so no code mints tokens.
Strategic alignment
- Parent: feat(k8s): the homelab runs gitea under argo cd as a read-write internal forge, served in-cluster over http and to workstations at https://git.<domain> through the cloudflare tunnel, with its admin secret pushed from the keyring #1081 (the Gitea family; order: feat(k8s): argo cd keeps the homelab cluster at the current release branch, with automated sync, prune and self-heal that never delete data #755 and feat(k8s): devops-cli runs in the homelab cluster as Jobs, and every cluster Secret is pushed from the keyring, also by deploy-stack (devops k8s push-secrets, devops k8s run-job) #741, then feat(k8s): the homelab runs gitea under argo cd as a read-write internal forge, served in-cluster over http and to workstations at https://git.<domain> through the cloudflare tunnel, with its admin secret pushed from the keyring #1081, then this item, then feat(k8s): Point Argo CD to Gitea for git and PR dev images #1082).
- Priority: P2. It is what makes Gitea usable for iteration, as the owner asked.
- Value / Effort: Medium / Medium. The work is a small API client, three subcommands, a sync step, settings, tests on temporary repositories, and docs. Moving from the NodePort to the HTTPS alias replaces the NodePort lookup with the existing Ingress discovery, and adds the Access-blocked error.
- Depends on:
- feat(k8s): the homelab runs gitea under argo cd as a read-write internal forge, served in-cluster over http and to workstations at https://git.<domain> through the cloudflare tunnel, with its admin secret pushed from the keyring #1081: Gitea deployed and reachable at
https://git.<domain>. The code merges without it, but the person checks need it. - feat(k8s): devops-cli runs in the homelab cluster as Jobs, and every cluster Secret is pushed from the keyring, also by deploy-stack (devops k8s push-secrets, devops k8s run-job) #741:
config setwith a hidden prompt.
- feat(k8s): the homelab runs gitea under argo cd as a read-write internal forge, served in-cluster over http and to workstations at https://git.<domain> through the cloudflare tunnel, with its admin secret pushed from the keyring #1081: Gitea deployed and reachable at
- Blocks: feat(k8s): Point Argo CD to Gitea for git and PR dev images #1082's trials (the Gitea remote on the devops-cli checkout and the API client).
- Related:
- refactor(github): one github session per identity owning token, quota and transport #767: gh as GitHub's credential source, the model for the helper.
- feat(devcontainer): configure ollama extension for vllm 16gib service with gpt-oss:20b #722: the devcontainer git daemon's "container repository synchronization". The daemon is removed by fix(security): the devcontainer no longer starts the git daemon stub meant for argo cd, which served every clone under repos/ without authentication on port 9418 #1122, which does not wait for this one.
- Source: the owner, 2026-10-03 (quotes above).
Update 2026-10-08: refinement
- Per test(cli): tests double only process edges and mirror the source tree #1307 (2026-10-07), assertions compare whole values, and the recorder sits at the process edge (refactor(cli): one process runner owns execution, process groups and dry-run #775's fake once it lands); new files follow test(cli): every test file sits in the directory mirroring the package it tests or in tests/invariants/, and the root conftest holds only the hermetic floor #1313's layout.
- The Gitea client is built at
configured_level()(http/egress.py:61). fetch_allandpull_trackingswallow errors (git/operations.py:202-221); fix(cli): repos sync and branches sync report a failed fetch or pull instead of printing success #1399 makes them raise, and this item's fetch-failure criterion builds on it.- Depends on fix(cli): repos sync and branches sync report a failed fetch or pull instead of printing success #1399, feat(k8s): the homelab runs gitea under argo cd as a read-write internal forge, served in-cluster over http and to workstations at https://git.<domain> through the cloudflare tunnel, with its admin secret pushed from the keyring #1081 and feat(k8s): devops-cli runs in the homelab cluster as Jobs, and every cluster Secret is pushed from the keyring, also by deploy-stack (devops k8s push-secrets, devops k8s run-job) #741.
Alternatives check of 2026-11-18: partly.
Tool: Langenfeld/py-gitea (https://github.com/Langenfeld/py-gitea), MIT, last activity 2026-11-06, maintained.
Reason: Searches found maintained Python Gitea clients, and py-gitea wraps organisations, repositories and users over the token API, so it covers part of the API-client work but not branch protections, remotes, the credential helper or Cloudflare Access handling.
Covers:
- Wraps Gitea organisations, repositories, teams and users
- Reads the server version and the token's user
- Token authentication against the Gitea REST API
Lacks:
- No branch-protection rule creation, README says not the full Swagger API
- No Cloudflare Access redirect or challenge detection
- No git remotes, credential helper, keyring token or sync step
Proposed design
Problem statement
Every clone under repos/ has only a GitHub origin remote. Gitea is the internal forge for iteration branches. The change adds a gitea remote to each clone, a Gitea API client, a git credential helper, devops repos gitea connect, devops repos remotes, and a devops repos sync step that carries GitHub's default branch to Gitea without forcing a push. Git runs through the existing process runner, not GitPython.
Acceptance criteria
Requirement: Gitea URL validation
The configuration SHALL define the settings gitea.url, gitea.username, gitea.github_branches and gitea.extra_checkouts, and the credential gitea.token; gitea.url SHALL be unset by default and SHALL accept only an https:// URL with no path.
Scenario: An HTTP URL is refused
- WHEN
gitea.urlis set tohttp://git.example.com - THEN settings validation raises an error and no token is sent.
Requirement: Gitea branch settings defaults
gitea.github_branches SHALL default to ["main"] and gitea.extra_checkouts SHALL default to an empty list.
Scenario: The defaults load
- WHEN a config file sets no
giteakeys - THEN the settings hold
["main"]and[].
Requirement: Gitea token credential
gitea.token SHALL be a Credential in CREDENTIALS with keyring name gitea_token and environment variable DEVOPS_CLI_GITEA_TOKEN.
Scenario: The token comes from the keyring
- WHEN
gitea.tokenis unset in the config file and the keyring holdsgitea_token - THEN the credential resolver returns the keyring value for
gitea.token.
Requirement: Hidden token prompt
devops config set gitea.token SHALL prompt for the token with hidden input when the value is omitted.
Scenario: The token is typed at a hidden prompt
- WHEN
devops config set gitea.tokenruns without a value - THEN the command reads the token at a hidden prompt and stores it in the keyring.
Requirement: Gitea client base
The Gitea client SHALL wrap one httpx2.Client from devops_cli.http.entry.http_client at configured_level().
Scenario: The client builds a version request
- WHEN
version()is called against aMockTransport - THEN the request URL is
<gitea.url>/api/v1/version.
Requirement: Gitea client headers
The Gitea client SHALL use base_url gitea.url plus /api/v1 and the header Authorization: token <token>.
Scenario: The client sends the token
- WHEN
current_user()is called - THEN the request carries
Authorization: token <token>.
Requirement: Gitea client paths and TLS
The Gitea client SHALL build request paths from path segments and SHALL verify TLS against the system store.
Scenario: A path segment is escaped
- WHEN
repois called with an owner that holds a slash - THEN the client builds the path from segments and sends no malformed URL.
Requirement: Gitea client typed calls
The Gitea client SHALL provide typed calls for version, current_user, org, create_org, repo, create_repo, branch_protections and create_branch_protection.
Scenario: A repository is created for the token's login
- WHEN
create_reporuns with an owner equal tocurrent_user.login - THEN the client sends
POST /api/v1/user/reposwithprivate: trueandauto_init: false.
Requirement: Cloudflare Access blocked
The Gitea client SHALL not follow redirects; it SHALL raise GiteaAccessBlocked for a redirect to another host or a 403 with cf-mitigated: challenge, naming the bypass policy and pointing to the guide in k8s/README.md.
Scenario: Cloudflare Access refuses a request
- WHEN the transport returns a 302 to another host or a 403 with
cf-mitigated: challenge - THEN
GiteaAccessBlockednames the bypass policy and the guide, and the token never appears in the message.
Requirement: Gitea errors mask the token
The Gitea client SHALL raise GiteaError for any other status, naming the call, the repository and Gitea's message, with the token masked by mask_secrets.
Scenario: Gitea returns an error
- WHEN
create_repogets HTTP 500 with a message that holds the token - THEN
GiteaErrornames the call and the repository and the message masks the token.
Requirement: Connect validates before token
devops repos gitea connect SHALL validate the URL before it reads the token.
Scenario: An HTTP URL is refused before a request
- WHEN
connect --url http://git.example.comruns - THEN the command exits 1, makes no request on the
MockTransportand reads no keyring value.
Requirement: Connect checks and saves
devops repos gitea connect SHALL check version and current_user, save gitea.url and gitea.username, and print the URL, login and version.
Scenario: Connect saves the login
- WHEN
connect --url https://git.example.comruns with a valid token - THEN the command saves
gitea.urlandgitea.usernameand prints the URL, login and version.
Requirement: Connect says to refresh remotes
devops repos gitea connect SHALL say to run devops repos remotes again when gitea.url changes.
Scenario: The URL changes
- WHEN
connectsaves a differentgitea.url - THEN the command prints the instruction to run
devops repos remotesagain.
Requirement: Connect discovers the Ingress host
devops repos gitea connect SHALL discover the Ingress host of gitea-http in namespace gitea when --url is absent.
Scenario: The URL comes from Ingress discovery
- WHEN
kubectl get ingress -A -o jsonis stubbed with agitea-httphost - THEN
connectuseshttps://<host>and saves it asgitea.url.
Requirement: Connect names a missing token
devops repos gitea connect SHALL exit 1 and name devops config set gitea.token when the token is missing.
Scenario: The token is missing
- WHEN
connectruns without a keyring token - THEN the command exits 1 and names
devops config set gitea.token.
Requirement: Connect names a missing Ingress
devops repos gitea connect SHALL exit 1 and name --url when no Ingress exists.
Scenario: No Gitea Ingress exists
- WHEN
connectfinds no Ingress host and--urlis absent - THEN the command exits 1 and names
--url.
Requirement: Connect reports Access blocked
devops repos gitea connect SHALL exit 1 with the message of GiteaAccessBlocked.
Scenario: Access blocks connect
- WHEN
connectgets aGiteaAccessBlockederror - THEN the command exits 1 and prints the error message.
Requirement: Remotes ensure the organisation
devops repos remotes SHALL ensure the Gitea organisation exists and SHALL create it only on 404.
Scenario: The organisation is absent
- WHEN
orgreturns 404 - THEN the client sends
POST /orgswithvisibility: private.
Requirement: Remotes use the user namespace
devops repos remotes SHALL skip organisation creation when the owner equals the token's login and SHALL create the repository under /user/repos.
Scenario: The owner is the token's login
- WHEN the clone's owner equals
current_user.login - THEN the client sends
POST /api/v1/user/reposand noPOST /orgs.
Requirement: Remotes ensure the repository
devops repos remotes SHALL ensure the repository exists, create it only on 404, and set default_branch to the clone's GitHub default branch.
Scenario: A repository is absent on Gitea
- WHEN
reporeturns 404 andcreate_reporuns - THEN the client creates the repository with
private: true,auto_init: falseand the GitHub default branch.
Requirement: Remotes read origin HEAD
devops repos remotes SHALL read the clone's GitHub default branch with git symbolic-ref --short refs/remotes/origin/HEAD through the process runner.
Scenario: The default branch is read from origin/HEAD
- WHEN
origin/HEADpoints torefs/remotes/origin/master - THEN the command reads
masteras the GitHub default branch.
Requirement: Remotes create protections
devops repos remotes SHALL create one branch protection for the GitHub default branch and each gitea.github_branches pattern that has no rule.
Scenario: A protection exists
- WHEN
branch_protectionsalready returns the rule - THEN no POST creates a second rule.
Requirement: Protection settings
Each created branch protection SHALL set rule_name to the pattern, enable_push: true, enable_force_push: false and list-order priority.
Scenario: A protection is created
- WHEN
create_branch_protectionruns - THEN the request body holds the pattern as
rule_name,enable_push: true,enable_force_push: falseand the pattern's list-order priority.
Requirement: Remotes set the remote URL
devops repos remotes SHALL create or update the gitea remote with git remote add or git remote set-url through the process runner, using gitea.url joined to <owner>/<name>.git, and SHALL leave origin and branch upstreams untouched.
Scenario: The remote URL changes
- WHEN
gitea.urlchanges andremotesruns again - THEN the
gitearemote URL is updated andoriginkeeps its URL.
Requirement: Remotes set the helper entries
devops repos remotes SHALL set credential.<gitea.url>.helper in the clone's config to an empty value and then to !devops repos gitea credential, and SHALL not touch global git config.
Scenario: The helper entries are written in order
- WHEN
remotesruns on a clone - THEN
git config --get-all credential.<gitea.url>.helperprints the empty entry then the!devopsentry.
Requirement: Remotes remove old helper entries
devops repos remotes SHALL remove the old URL's helper entries when the URL changes.
Scenario: The URL changes
- WHEN
gitea.urlchanges andremotesruns again - THEN the old URL's
credential.<old-url>.helperentries are removed.
Requirement: Remotes set checkout defaults
devops repos remotes SHALL set checkout.defaultRemote to origin and remote.gitea.tagOpt to --no-tags in the clone's config.
Scenario: A clone has both remotes
- WHEN
remotesruns - THEN the clone's config holds
checkout.defaultRemote=originandremote.gitea.tagOpt=--no-tags.
Requirement: Remotes seed the default branch
devops repos remotes SHALL seed the GitHub default branch and every matching origin branch with refs/remotes/origin/<branch>:refs/heads/<branch>.
Scenario: The first run seeds main
- WHEN the bare
gitearepository has nomain - THEN the first run pushes
origin/maintogitearefs/heads/main.
Requirement: Remotes use the GitHub default branch
devops repos remotes SHALL use the clone's GitHub default branch from refs/remotes/origin/HEAD and SHALL create, protect, seed and sync that branch when it is not main.
Scenario: The GitHub default branch is master
- WHEN the clone's
origin/HEADnamesmaster - THEN
remotescreatesmasteras Gitea's default branch, protects it and seeds it.
Requirement: Remotes are idempotent
A second devops repos remotes run with no change SHALL make only GET calls, run no push, and print no created row.
Scenario: A second run changes nothing
- WHEN
remotesruns twice with no change - THEN the transport records only GET requests, no push runs, and the table shows no created row.
Requirement: Remotes dry run
devops repos remotes --dry-run SHALL print the plan per clone and SHALL make only GET calls.
Scenario: A dry run makes no write
- WHEN
remotes --dry-runruns against aMockTransport - THEN the transport records only GET requests and the table shows the plan.
Requirement: Remotes record extra checkouts
devops repos remotes SHALL cover each clone from iter_workspace_repos, each gitea.extra_checkouts entry and each --path, and SHALL record each resolved --path once in gitea.extra_checkouts, using gh repo view --json owner,name for a checkout outside repos/.
Scenario: A path outside repos is added
- WHEN
remotes --path /workspaces/devops-cliruns twice - THEN
gitea.extra_checkoutsholds the resolved path once and the owner and name come fromgh repo view.
Requirement: Remotes skip standalone clones
devops repos remotes SHALL skip repos/_standalone/* with a note.
Scenario: A standalone clone is skipped
- WHEN
iter_workspace_reposyieldsrepos/_standalone/tool - THEN the command prints a skip note and makes no Gitea call for it.
Requirement: Remotes report one table
devops repos remotes SHALL print one table with columns clone, created, protected, remote and seeded, and SHALL continue after a failed clone with exit code 1.
Scenario: A clone fails
- WHEN one clone raises
GiteaError - THEN the command reports that clone, continues with the rest, and exits 1.
Requirement: Remotes stop on Access blocked
devops repos remotes SHALL stop the run at the first clone when GiteaAccessBlocked occurs.
Scenario: Access blocks the first clone
- WHEN the first clone raises
GiteaAccessBlocked - THEN the command stops and makes no call for a later clone.
Requirement: Credential helper is hidden
The devops repos gitea credential command group SHALL be hidden from --help.
Scenario: The helper is hidden
- WHEN
devops repos gitea --helpruns - THEN the output does not list
credential.
Requirement: Credential get reads stdin
devops repos gitea credential get SHALL read git's key=value lines from stdin and print username and password only for an https host with any port that matches gitea.url.
Scenario: A matching host returns the token
- WHEN stdin holds
protocol=httpsandhost=git.example.com - THEN the helper prints
username=<gitea.username>andpassword=<keyring token>.
Requirement: Credential get ignores other hosts
devops repos gitea credential get SHALL print nothing for any other protocol or host.
Scenario: Another host gets no answer
- WHEN stdin holds
protocol=httpsandhost=example.com - THEN the helper prints nothing.
Requirement: Credential get makes no request
devops repos gitea credential get SHALL make no network call.
Scenario: The helper reads the keyring
- WHEN the helper gets a matching host
- THEN the
MockTransportrecords no request.
Requirement: Credential store and erase do nothing
devops repos gitea credential store and erase SHALL do nothing, and the token SHALL never reach argv, a log or a file.
Scenario: The helper starts no command with the token
- WHEN the credential helper runs with a recording
run_subprocessstub - THEN no argument list holds the token, the keyring is unchanged, and no output holds the token.
Requirement: Sync fetches both remotes
devops repos sync SHALL fetch both remotes through fetch_all, which raises GitOperationError for a failed fetch.
Scenario: Sync fetches origin and gitea
- WHEN
syncruns on a clone with both remotes - THEN the command fetches
originandgitea.
Requirement: Sync can turn the Gitea push off
devops repos sync SHALL push to Gitea by default and --no-gitea SHALL turn the push off.
Scenario: The Gitea push is turned off
- WHEN
sync --no-gitearuns - THEN the command fetches both remotes and makes no Gitea push.
Requirement: Sync pushes the default branch
devops repos sync SHALL push refs/remotes/origin/<branch>:refs/heads/<branch> for the GitHub default branch and each matching gitea.github_branches pattern without force.
Scenario: Sync carries main to Gitea
- WHEN
origin/mainis ahead ofgitea/main - THEN sync fast-forwards
gitea/mainand reports success.
Requirement: Sync matches branch names
devops repos sync SHALL match branch names with PurePosixPath(branch).full_match(pattern), where * does not cross /.
Scenario: A nested branch does not match
- WHEN
gitea.github_branchesholdsrelease/*and origin hasrelease/1/fix - THEN sync does not push
release/1/fix.
Requirement: Sync reads porcelain results
devops repos sync SHALL run git push --porcelain through the process runner and SHALL read each branch's result from the porcelain status lines.
Scenario: A successful branch is read from porcelain
- WHEN
git push --porcelainprints a*line formain - THEN sync reports
mainas updated.
Requirement: Sync reports a rejected branch
devops repos sync SHALL report a rejected non-fast-forward per branch from the ! line of git push --porcelain with git log gitea/<branch> ^origin/<branch> and SHALL continue with the next branch.
Scenario: A diverged main is rejected
- WHEN
git push --porcelainprints!formain - THEN sync reports the branch as rejected, names the inspection command, and leaves
gitea/mainunchanged.
Requirement: Sync skips a push after a failed fetch
devops repos sync SHALL report a failed fetch from origin or gitea and SHALL skip that clone's Gitea push.
Scenario: A fetch fails
- WHEN
fetch_allraises fororiginorgitea - THEN sync reports the failure and makes no Gitea push for that clone.
Requirement: Sync never pushes an iteration branch
devops repos sync SHALL never push an iteration branch.
Scenario: An iteration branch exists on origin
- WHEN
origin/topicmatches nogitea.github_branchespattern - THEN sync makes no push for
topic.
Requirement: Clone runs the Gitea ensure step
devops repos clone and clone-org SHALL run the same Gitea ensure step for each new clone when gitea.url is set.
Scenario: A new clone gets the remote
- WHEN
clonecreates a clone andgitea.urlis set - THEN the clone gets the
gitearemote and the helper entries.
Requirement: Clone keeps a Gitea failure as a warning
A Gitea failure in that step SHALL be a warning that keeps the clone.
Scenario: The Gitea ensure step fails after a clone
- WHEN
clonecreates a clone and the Gitea call raisesGiteaError - THEN the command warns and the clone remains.
Requirement: Offline test harness
The Gitea remotes tests SHALL run offline with git_fake transcripts for git and an httpx2.MockTransport for Gitea, in tests/gitea/ and tests/commands/test_repos.py.
Scenario: A test runs with no network
- WHEN the Gitea remotes test suite runs
- THEN no real git starts, no network request leaves the process, and the suite finishes under one second.
Requirement: Generated docs are current
The change SHALL add help strings in lang/en/help.py, regenerate docs/commands/repos.md and docs/CLI_REFERENCE.md, and add a Gitea remotes section to the page that documents devops repos.
Scenario: The docs check passes
- WHEN
devops docs generateruns anddevops docs checkruns - THEN
docs checkexits 0 anddocs/commands/repos.mdholds the Gitea remotes section.
Requirement: Readiness and CI
devops pr check-readiness and uv run devops ci SHALL pass within the 5-minute budget.
Scenario: The gate passes
- WHEN
devops pr check-readinessanduv run devops cirun - THEN both exit 0 within 5 minutes.
Existing Tool Considered
The alternatives check of 2026-10-29 returned not-applicable and found no tool. No single open, maintained tool covers the whole need. tea v0.16.0 has no branch-protection command and keeps its token in plain text under $XDG_CONFIG_HOME/tea; Gitea's official SDK is Go; no maintained Python client covers organisation, repository and branch-protection creation. The change builds a thin client on the existing httpx2 dependency and runs git through the existing process runner. Written cost: about 30,000 tokens to build, 10,000 tokens to keep and fix, and 3 to 4 days elapsed.
Key questions
- Which side is authoritative for what?: GitHub owns each repository's default branch, tags, pull requests, CI and releases. Gitea owns every other branch, the iteration branches. (best practice) [sources: k8s/README.md:959]
- Chosen: GitHub default branch and Gitea iteration branches. It follows the existing flow: pull requests target the GitHub default branch, and CI and releases run there.
- Rejected: Gitea as a full mirror. A pull mirror is read-only and a push mirror force-pushes every ref, so neither keeps a writable Gitea in step.
- Rejected: Dual write to both forges. It adds a second writer and a second credential without a check.
- How do the two stay in step, with the fewest moving parts?: Through
devops repos syncon the workstation.fetch_allalready fetches every remote with prune and raises on a failed fetch, and sync fast-forwards Gitea's default branch fromoriginwithout force. (best practice) [sources: src/devops_cli/git/operations.py:264-275, src/devops_cli/commands/repos.py:317-352, k8s/README.md:959]- Chosen: Workstation sync through
devops repos sync. The workstation already holds both remotes and both credentials, andfetch_allalready fetches every remote. - Rejected: Gitea pull mirror. A pull mirror refuses pushes, so it cannot hold iteration branches.
- Rejected: Gitea push mirror. A push mirror force-pushes every ref and would erase GitHub's merges.
- Rejected: In-cluster sync job. It is a new component with its own GitHub credential.
- Chosen: Workstation sync through
- What if someone pushes to
mainon Gitea?: GitHub ownsmain, so a divergent push to Gitea'smainis not a supported write. Gitea's branch protection refuses a force-push and a deletion. A plain divergent push makes the next sync report the branch as rejected. A person inspects it and resets Gitea's branch withgit push --force-with-lease=main gitea origin/main:mainafter lifting the rule, or moves the commits to an iteration branch. (best practice) [sources: k8s/README.md:959]- Chosen: Protection plus rejected sync report. It needs no second token and the next sync shows the divergence.
- Rejected: Separate sync account with a push allowlist. It blocks the case but costs a second token and a second credential.
- Why not a
devops repos pushwrapper?:git push gitea <branch>already does the job once the remote and the credential helper exist. A wrapper adds a command without adding a check;devops repos syncis the only bulk write, and it is limited to the default branch andgitea.github_branches. (best practice) [sources: src/devops_cli/commands/repos.py:317-352, k8s/README.md:959]- Chosen: Direct
git push gitea <branch>. The remote and the helper make the push work without a new command. - Rejected: A
devops repos pushwrapper. It adds a command and no check.
- Chosen: Direct
- Which URL do the remotes use?: The tunnel alias over HTTPS,
https://git.<domain>. In-cluster HTTPhttp://gitea-http.gitea.svc.cluster.local:3000is for pods and Argo CD only. (best practice) [sources: k8s/README.md:963-966, k8s/README.md:959]- Chosen: Tunnel alias over HTTPS. The owner decided it on 2026-10-03 and the workstation reaches Gitea through the Cloudflare tunnel.
- Rejected: In-cluster HTTP. It is for pods and Argo CD only, not for the workstation.
- How does git authenticate?: A URL-scoped git credential helper in each clone reads the keyring token. It is the same shape as
gh auth git-credentialfor GitHub, which the devcontainer sets with an empty entry followed by the helper. Cloudflare Access passes through the public-IP bypass policy, and Gitea's token is the authentication. (best practice) [sources: .devcontainer/image/devcontainer.json:36-44, src/devops_cli/templates/devcontainer.json.j2:47-55, k8s/README.md:980-991]- Chosen: URL-scoped credential helper in each clone. It keeps the token out of the remote URL and out of committed files, and git calls it only for the Gitea URL.
- Rejected: Token in the remote URL. It puts the token on disk and in process arguments.
- Rejected: Token in
http.extraHeader. It puts the token on disk. - Rejected: tea's credential helper. It keeps the token in plain text under
$XDG_CONFIG_HOME/tea.
- HTTPS or SSH?: HTTPS. Gitea has SSH off, and through the tunnel it would need
cloudflared access sshon every client. (best practice) [sources: k8s/README.md:966, k8s/README.md:971]- Chosen: HTTPS. It uses the tunnel host and the Gitea token, and Gitea has SSH off.
- Rejected: SSH. Gitea has SSH off and the tunnel would need a client-side access command.
- Where do owner and name come from?: For
repos/<org>/<name>they are the directory names. For a checkout outsiderepos/, they come fromgh repo view --json owner,name. No remote URL is parsed by hand. (best practice) [sources: src/devops_cli/commands/repos.py:236-260, src/devops_cli/git/operations.py:70-82, src/devops_cli/git/operations.py:142-164]- Chosen: Directory names and
gh repo view. The layout already enforces the owner and name, andgh repo viewgives the same fields for a checkout outside it. - Rejected: Parse the
originremote URL. It handles fewer URL forms and duplicates whatgh repo viewalready answers.
- Chosen: Directory names and
- Should the main
/workspaces/devops-clicheckout get the remote too?: Yes.devops repos remotes --path /workspaces/devops-cliadds it and records the path ingitea.extra_checkouts, sodevops repos synccovers it.iter_workspace_reposcovers only two levels underrepos/, so an outside checkout has no other way into sync. (best practice) [sources: src/devops_cli/git/operations.py:70-82, k8s/README.md:959]- Chosen: Yes, with
--pathandgitea.extra_checkouts. Agents iterate in worktrees of that checkout, and feat(k8s): Point Argo CD to Gitea for git and PR dev images #1082's trials deploy devops-cli branches from Gitea. - Rejected: No, leave that checkout on GitHub only. Its Gitea
mainwould stay at the first seed.
- Chosen: Yes, with
- Which token scopes?:
write:repositoryfor push, repository creation and branch protection;write:organizationto create organisations; andread:userforGET /user. The owner creates the token in Gitea's UI once, so no code mints tokens. (proposed)- Chosen: The three least scopes. They cover the API calls the client makes and no more.
- Rejected: An administrator token. It grants more than the client needs and raises the harm of a leak.
- Which git interface and test harness does the change use?: Git runs through the one process runner (
run_subprocess), not GitPython, which is no longer a dependency. Tests answer every git command from agit_faketranscript and start no real git. [sources: docs/TESTING.md:80, pyproject.toml:11-85, src/devops_cli/git/operations.py:264-275] - How are managed credentials declared?: A managed credential is a
Credentialentry inCREDENTIALSinconfig/env.py. The keyring name is the key with_for.and the environment variable isDEVOPS_CLI_plus the upper-cased key, sogitea.tokengivesgitea_tokenandDEVOPS_CLI_GITEA_TOKEN._SECRET_FIELDSderives from the credential table, sodevops config setprompts hidden. [sources: src/devops_cli/config/env.py:46-71, src/devops_cli/config/settings.py:179, src/devops_cli/commands/config.py:211-221] - How is a new settings section declared?: As a pydantic model with
extra="ignore",validate_assignment=Trueandhide_input_in_errors=True, added as a field onSettings; a credential is aCredentialentry inCREDENTIALSand needs no settings field. [sources: src/devops_cli/config/settings.py:1502-1537, src/devops_cli/config/settings.py:1561-1590, src/devops_cli/config/env.py:46-71] - Which HTTP client builds the Gitea client?: The one entry point
devops_cli.http.entry.http_clientatconfigured_level(), which admits the configured URL and is answered by the test transport seam. [sources: src/devops_cli/http/entry.py:52-75, src/devops_cli/http/egress.py:67-78, ARCHITECTURE.md:214] - How does connect discover the Gitea Ingress host?: It reuses
_discover_ingress_hostsand_find_service_ingress_urlincommands/k8s/networking.py, the discovery thatdevops k8s configure-urls --addressing fqdnuses. [sources: src/devops_cli/commands/k8s/networking.py:683, src/devops_cli/commands/k8s/networking.py:749] - How does sync read each branch's push result without GitPython?: It runs
git push --porcelainthrough the process runner and reads the porcelain status lines:*for a successful update and!for a rejection, with the ref names. It does not parse human-readable output. (best practice) [sources: docs/TESTING.md:80, src/devops_cli/git/operations.py:264-275]- Chosen: Read
git push --porcelainstatus lines. The porcelain format is machine-readable and carries the ref name and result for each branch. - Rejected: Use the exit code alone. It reports only that some branch failed, not which branch, so the run cannot continue per branch.
- Rejected: Parse human-readable git output. The text changes with git's version and locale.
- Chosen: Read
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNew
- StatusShow more project fieldsNew
Activity
[-]feat(repos): every clone under repos/ keeps a gitea remote next to origin, created on gitea when missing, with github's main and release branches carried over by devops repos sync[/-][+]feat(repos): every clone under repos/ keeps a gitea remote at https://git.<domain> next to origin, created on gitea when missing, with github's main and release branches carried over by devops repos sync[/+][-]feat(repos): every clone under repos/ keeps a gitea remote at https://git.<domain> next to origin, created on gitea when missing, with github's main and release branches carried over by devops repos sync[/-][+]feat(repos): every clone under repos/ keeps a gitea remote at https://git.<domain> next to origin, created on gitea when missing, with github's main branch carried over by devops repos sync[/+]dan-petty commentedon Oct 28, 2026
Refine cannot set this item to Ready at 69636b6 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.
main, tags, and everything that reviews, tests or ships them.mainon GitHub, CI runs there, and the release workflow publishes from there.mainlags until someone syncs. Only people and agents at a workstation read it, and they sync first. Argo CD reads GitHub (feat(k8s): Point Argo CD to Gitea for git and PR dev images #1082).git push --force-with-lease=main gitea origin/main:mainafter lifting the rule, or moves the commits to an iteration branch.https://git.that reads the keyring token. It is the same shape asgh auth git-credentialfor GitHub.http.extraHeader, puts it on disk. tea's helper keeps the token in plain text.git-credential-libsecretkeeps a second copy under other keyring attributes.devops-cli-service commentedon Oct 29, 2026
Alternatives check: not-applicable
Tool: none found
Checked on 2026-10-29. A person decides what this means for the item. The check changes no label and closes no issue.
[-]feat(repos): every clone under repos/ keeps a gitea remote at https://git.<domain> next to origin, created on gitea when missing, with github's main branch carried over by devops repos sync[/-][+]feat(repos): Add a gitea remote to every clone under repos/[/+]1 remaining item
devops-cli-service commentedon Nov 12, 2026
Status set to Ready at 87ae9ee (see proposed design in issue body).
Moved to new items: #5000.
devops-cli-service commentedon Nov 18, 2026
The result in the alternatives block of the issue body changed. Before this check:
not-applicable, no tool. A person decides what the new result means for the item.Searches (10)
Tools considered:
Searches run:
Sources:
fix(repos): pass config declarations, dry-run ratchet, and tool snaps…
test(repos): add edge case coverage for gitea settings, client, remot…
fix(gitea): move domain exceptions to devops_cli.exceptions.gitea and…
devops-cli-service commentedon Nov 19, 2026
Released in v0.181.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.181.0
devops-cli-service commentedon Nov 19, 2026
Live since 2026-11-19 17:17 UTC