4 Commits
Author SHA1 Message Date
AlexKucera 9d585f601a 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
2026-08-11 16:31:58 +02:00
AlexKucera 1613ec72b8 refactor(migrator): centralize git in GitRunner
CI / test (push) Canceled after 0s
Introduce git.GitRunner as the sole git-op seam: the only place git is
invoked. It owns subprocess execution, per-op timeout, error redaction, and
auth delivery. Forge tokens move off the remote URL entirely onto a
non-persisted per-op http.<host>.extraHeader, so they never reach the
command line, a remote URL, or .git/config.

Rewrite the mirror procedure to drive GitRunner and retire the URL-token
helpers (_authed/_bare/_redact/_scrub_remote_tokens) plus the try/finally
scrub -- their reason to exist vanishes. mirror_repo's signature and report
stay unchanged; cli/migrate import the re-exported GitError/timeout
unchanged. The procedure's ordering invariants are now locked by a
recording-fake test, and an AST guard fails the suite if any git op bypasses
the seam.

Closes the 2026-08-11 audit's HIGH (token in GitError) and MEDIUM (token
in .git/config) at one structural root cause.

Closes #1
2026-08-11 15:36:35 +02:00
AlexKucera ab43b0311e feat: implement Codeberg → Gitea repo migrator
Replay git (mirror + LFS), 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 rewrites #NNN and
URL cross-references to the target number space; deleted-branch PR
heads are recreated as refs/heads/_pr/<n>.

CLI: codeberg-to-gitea migrate owner/name  (CODEBERG_TOKEN/GITEA_TOKEN)
Verified end-to-end on AlexKucera/helm: 283 issues, 1 PR, 19 labels,
219 comments, git history, with cross-refs correctly rewritten.
2026-08-11 11:12:06 +02:00
AlexKucera 601cf4c41e chore: bootstrap project scaffold
CI / test (push) Canceled after 0s
Set up the codeberg-to-gitea-migrator project: Python package
with src/ layout (hatchling, ruff, pytest), GPL-3.0-or-later
license, CITATION.cff, README, ADRs for stack/license/forge, and
DOX-structured AGENTS.md. Add Gitea Actions CI.

The package is a stub; migration modules land in follow-up commits.
2026-08-11 09:46:13 +02:00