The migrator was fully synchronous — every HTTP round-trip and git op serialized over one blocking client, and a stalled git push could hang it forever. Overlap the independent phases and bound the slow / memory-heavy paths. - clients: ApiClient is now thread-safe (per-thread httpx.Client) so labels, milestones, Pass-B comments, and release assets overlap via parallel(); --concurrency sizes it (default 8). Pass A issue/PR creation stays serial — entities are created in source-number order so the number map resolves forward cross-references. - releases: stream assets through a spooled temp file instead of buffering each whole into memory; upload them concurrently. - reliability: per-op --git-timeout (was unbounded hangs), a circuit breaker that aborts on a degraded target, jittered retry backoff, and a bulk timeout for large asset transfers. - round-trips: set an issue's milestone in the create body; batch the deleted-branch PR-head git push and refs/pull/* pruning. - fix: raw_get_stream 4xx/5xx raised AttributeError (resp.read().text on bytes) instead of ApiError — now decodes. Wrap mirror git ops in try/finally so tokenized remote URLs are scrubbed even on timeout. - refactor: drop the typer dependency — the CLI is now stdlib argparse (same subcommands, flags, and env vars); remove dead code surfaced by a whole-repo audit (has_lfs, name_map, unused owner_repo param, stored-but-unread _base_url). - ci: enable the uv download cache. Tests cover parallel ordering, the circuit breaker, and the streamed 4xx path. CHANGELOG updated; the runtime dependency is now just httpx.
This commit is contained in:
1 parent
867d982786
commit
137734673d
14 files changed
+1372
-299
No files matched your search
@@ -9,6 +9,26 @@ All notable changes to this project will be documented in this file. The format
|
||||
- **migrator:** keep forge API tokens out of error text and on-disk git config. Git failures now surface a redacted `oauth2:***@` URL instead of the live token, and the CLI catches `GitError` with a clean message instead of dumping a traceback. The mirror's remote URLs are scrubbed to bare form after each run (no token persisted in `.git/config`), and the default workdir is per-user `0700` (`/tmp/cb2gitea-<uid>`) so it isn't world-readable on shared hosts.
|
||||
- **deps:** reproducible, hash-verified installs — commit `uv.lock` and install from it in CI (`uv sync --frozen`); pin Gitea Actions to commit SHAs instead of mutable `@vN` tags; pin the ruff rule set explicitly (`select = ["E4","E7","E9","F"]`) and exclude `audit/`.
|
||||
|
||||
### perf
|
||||
|
||||
- **migrator:** parallelize the independent migration phases. A single `ApiClient` is now thread-safe (each worker transparently gets its own underlying `httpx.Client` via 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 push` carries all deleted-branch PR-head refspecs, and `update-ref --stdin` prunes all `refs/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 redacted `GitError` instead 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-python` `cache: uv`) so warm runs skip re-fetching deps; installs stay `--frozen`/hash-verified.
|
||||
|
||||
### refactor
|
||||
|
||||
- **cli:** drop the `typer` dependency; the CLI now uses stdlib `argparse` (same `migrate`/`version` subcommands, flags, and `CODEBERG_TOKEN`/`GITEA_TOKEN` env vars). Removes `typer` and its transitive `rich`/`shellingham` from the install (3 fewer packages).
|
||||
- **migrator:** remove dead code surfaced by a whole-repo over-engineering audit — `has_lfs`/`LFS_MARKERS` (uncalled), the `name_map` return of `migrate_labels` (sole caller discarded it), the unused `owner_repo` rewrite 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 as `refs/heads/_pr/<n>`. Tokens via `CODEBERG_TOKEN`/`GITEA_TOKEN`; `--repo owner/name` (or bare name). `--delete-existing` for clean re-runs.
|
||||
|
||||
Reference in new issue
Block a user