CI / test (push) Canceled after 0s
Pass-B writes (issue body rewrite + each comment) ran only at the caller's --concurrency, so a transient target 5xx either aborted the run or silently lost the write. A self-hosted Gitea throws bursts of 500s under concurrent writes, losing comments and leaving bodies with stale cross-refs. Failed writes are now deferred and replayed once serially (concurrency 1) after the concurrent wave -- serial load removes the backpressure causing the 500s, so nearly all recover. Writes still failing serially are logged and skipped; a genuinely-down target still aborts via CircuitOpenError. Adds two phase tests: persistent-fail (no abort) and transient (recover).
6.6 KiB
6.6 KiB
Changelog
All notable changes to this project will be documented in this file. The format is based on Common Changelog and this project adheres to Semantic Versioning.
[Unreleased]
security
- migrator: keep forge API tokens out of error text, the command line, and on-disk git config. Git auth is delivered through a single
git.GitRunnerseam as a non-persisted per-ophttp.<host>.extraHeader(Authorization: token <T>), so the token never enters a remote URL or.git/config; failures raise a redactedGitError(known-secret +oauth2:fallback) and the CLI catches it cleanly. The default workdir stays per-user0700. Closes the 2026-08-11 audit's HIGH (token in error text) and MEDIUM (token in git config) at one structural root cause. - deps: reproducible, hash-verified installs — commit
uv.lockand install from it in CI (uv sync --frozen); pin Gitea Actions to commit SHAs instead of mutable@vNtags; pin the ruff rule set explicitly (select = ["E4","E7","E9","F"]) and excludeaudit/.
perf
- migrator: parallelize the independent migration phases. A single
ApiClientis now thread-safe (each worker transparently gets its own underlyinghttpx.Clientvia a thread-local), so label/milestone creation, the Pass-B comment rewrite+upload, and per-release asset upload overlap through a bounded thread pool. New--concurrency(default 8) sizes it; Pass A issue/PR creation stays serial (entities must be created in source-number order so the number map resolves forward refs). - migrator: stream release assets through a spooled temp file (
raw_get_stream) instead of buffering each binary whole into memory, and upload them concurrently — peak memory is bounded (~1 MiB) regardless of asset size. - migrator: set an issue's milestone in the create body instead of a follow-up PATCH (PRs still PATCH — the pull-create endpoint has no milestone field). One fewer round-trip per milestoned issue.
- migrator: batch git operations — one
git pushcarries all deleted-branch PR-head refspecs, andupdate-ref --stdinprunes allrefs/pull/*in one process (was one spawn per ref).
fix
- migrator: every network git op (
clone --mirror,fetch,push --mirror, PR-head push, LFS fetch/push) now runs under a per-op timeout (--git-timeout, default 1800s) so a stalled TCP connection aborts with a redactedGitErrorinstead of hanging the migration forever. - client: circuit breaker — once
--fail-fast(default 5) consecutive requests exhaust their retries with no success in between, the run aborts (CircuitOpenError) instead of churning through every remaining item for hours on a degraded target. - client: add full jitter to the retry backoff and a larger, write-aware timeout (
httpx.Timeout(read=600, write=600)) for bulk asset transfers so large binaries stop timing out mid-transfer and re-uploading from scratch. - migrator: log unparseable pull refs instead of dropping them silently.
- ci: enable the uv download cache (
setup-pythoncache: uv) so warm runs skip re-fetching deps; installs stay--frozen/hash-verified. - migrator: defer-and-serially-retry Pass-B writes (issue body/title rewrites and each comment) that hit a transient target 5xx. Concurrent writes are what overstress a self-hosted Gitea into bursts of 500s, so a run either aborted or silently lost comments and left issue bodies with stale cross-refs. Failed writes are now deferred during the concurrent pass and replayed once serially (concurrency 1) afterwards — serial load removes the backpressure causing the 500s, so nearly all recover. Writes still failing serially are logged and skipped; a genuinely-down target still aborts via
CircuitOpenError.
refactor
- migrator: bind the repo-transfer context in a frozen
Migrationhandle (source + targetApiClients,owner,name,NumberMap). The four entity phases (migrate_labels/migrate_milestones/migrate_issues_and_prs/migrate_releases) take the handle instead of five loose params, so the source/target clients and owner/name can no longer drift between phases (an owner↔name transposition is now impossible to express);migrate_repobuilds one and drives all phases with it. RetiresRefCtxand the shared_pathhelper — absorbed into the handle's.path()/.rewrite()accessors (rewritedelegates to the existing pure rewriter via the bound clients' web roots).migrate_issues_and_prsnow mutatesm.numbersin place (returnsNone). Addstests/test_phases.py: the previously-untested entity layer is reachable through the seam (two mock-transport clients + a number map, no network). Behavior unchanged. Closes #2. - cli: drop the
typerdependency; the CLI now uses stdlibargparse(samemigrate/versionsubcommands, flags, andCODEBERG_TOKEN/GITEA_TOKENenv vars). Removestyperand its transitiverich/shellinghamfrom the install (3 fewer packages). - migrator: introduce
git.GitRunneras the sole git-op seam — the only place git is invoked. The mirror procedure (mirror.py) is rewritten to drive it (run/capture/okverbs;Forgevalue type for per-op auth), retiring the URL-tokenization, token-stripping, and on-exit config-scrub helpers (their reason to exist vanishes). The procedure's ordering invariants (pull-head capture → prune → mirror push → deleted-branch PR-head restore → LFS) are now locked by a recording-fake test; an AST guard fails the suite if any git op bypasses the seam. - migrator: remove dead code surfaced by a whole-repo over-engineering audit —
has_lfs/LFS_MARKERS(uncalled), thename_mapreturn ofmigrate_labels(sole caller discarded it), the unusedowner_reporewrite param, and a stored-but-unread_base_url.
feat
- migrator: working Codeberg → Gitea migration via
codeberg-to-gitea migrate. Mirrors git (code, history, tags, LFS) and replays labels, milestones, issues & PRs (with comments), and releases (with assets) entity-by-entity over the shared Forgejo/Gitea REST API. Two-pass issue/PR creation with#NNN/URL cross-reference rewriting to the target's number space; deleted-branch PR heads recreated asrefs/heads/_pr/<n>. Tokens viaCODEBERG_TOKEN/GITEA_TOKEN;--repo owner/name(or bare name).--delete-existingfor clean re-runs.
chore
- project: bootstrap scaffold — Python package (
src/layout, hatchling, ruff, pytest), GPL-3.0-or-later license, Gitea Actions CI, CITATION.cff, README, ADRs, and DOX-structured AGENTS.md. - deps: add
httpx,typer; addcodeberg-to-giteaconsole script.