5 Commits
Author SHA1 Message Date
AlexKucera 8ec9ce49db refactor(migrator): own _pr/N PR-head contract
CI / test (push) Canceled after 0s
Extract the duplicated `_pr/<n>` deleted-branch PR-head branch name
into a single pure helper `refs.pr_head_branch(n)`, now the only
definition. The git-mirror layer (mirror.py) and the REST/entity
layer (issues.py) both call it instead of spelling the pattern, so
the two can no longer diverge — editing one side previously broke
the other silently and late (404/500 on PR create for deleted-branch
PRs only).

Behavior-preserving string round-trip. refs.py widens from
"cross-reference rewriting" to "reference-namespace knowledge"
(branch-name patterns + cross-ref rewriting), still pure stdlib. No
new test — a shared symbol prevents divergence by construction
(issue #3 testing decision); the deleted-branch round-trip stays
covered by the existing phase test seam.

Closes #3
2026-08-11 17:26:46 +02:00
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 867d982786 chore: ignore agent tooling, record GitNexus docs
Add .pi-subagents/, .claude/, and CLAUDE.md to .gitignore, and append the GitNexus code-intelligence instructions to the root AGENTS.md.
2026-08-11 13:35:47 +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