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
This commit is contained in:
AlexKucera committed 2026-08-11 17:26:46 +02:00
1 parent 9d585f601a
commit 8ec9ce49db
8 files changed
+107 -13

No files matched your search

+3 -1
View File
@@ -19,7 +19,9 @@ shared Forgejo/Gitea REST API for full control.
references and source URLs are rewritten to the target's number space.
- **Pull-request heads** — when the source branch was deleted (common for
merged/closed PRs), the head commits are recreated on the target as
`refs/heads/_pr/<n>` so the PR can be rebuilt.
`refs/heads/_pr/<n>` so the PR can be rebuilt. That `_pr/<n>` branch name is
owned by one symbol — `refs.pr_head_branch` — shared by the mirror and the
issue/PR phase, so the two layers cannot diverge.
- **Releases & assets** — non-draft releases with binary assets re-uploaded.
## Requirements