refactor(migrator): bind repo-transfer context in Migration
CI / test (push) Canceled after 0s

Introduce a frozen Migration handle binding the identity quintet
(src/tgt clients, owner, name, NumberMap) the four entity phases
previously received as five loose params. The phases now take the
handle; migrate_repo builds one and drives all phases with it.
Retire RefCtx and the shared _path helper (absorbed into the
handle's .path()/.rewrite() accessors), deleting code rather than
leaving dead types. migrate_issues_and_prs mutates m.numbers in
place (returns None).

Add tests/test_phases.py: the previously-untested entity layer is
now reachable through the Migration seam (two mock-transport
clients + a number map, no network), covering the two-pass issue/PR
flow, label/milestone mappings, state-setting, best-effort PR merge,
the deleted-branch head fallback, and release+asset re-upload.

Closes #2
This commit is contained in:
AlexKucera committed 2026-08-11 16:31:58 +02:00
1 parent 1613ec72b8
commit 9d585f601a
12 files changed
+654 -124

No files matched your search

+1
View File
@@ -26,6 +26,7 @@ All notable changes to this project will be documented in this file. The format
### refactor
- **migrator:** bind the repo-transfer context in a frozen `Migration` handle (source + target `ApiClient`s, `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_repo` builds one and drives all phases with it. Retires `RefCtx` and the shared `_path` helper — absorbed into the handle's `.path()`/`.rewrite()` accessors (`rewrite` delegates to the existing pure rewriter via the bound clients' web roots). `migrate_issues_and_prs` now mutates `m.numbers` in place (returns `None`). Adds `tests/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 `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:** introduce `git.GitRunner` as the sole git-op seam — the only place git is invoked. The mirror procedure (`mirror.py`) is rewritten to drive it (`run`/`capture`/`ok` verbs; `Forge` value 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), the `name_map` return of `migrate_labels` (sole caller discarded it), the unused `owner_repo` rewrite param, and a stored-but-unread `_base_url`.