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
@@ -15,7 +15,7 @@ from pathlib import Path
|
||||
|
||||
from .clients import ApiClient, ApiError
|
||||
from .issues import RefCtx, migrate_issues_and_prs, migrate_labels, migrate_milestones
|
||||
from .mirror import mirror_repo
|
||||
from .mirror import DEFAULT_GIT_TIMEOUT, mirror_repo
|
||||
from .refs import NumberMap
|
||||
from .releases import migrate_releases
|
||||
|
||||
@@ -124,6 +124,8 @@ def migrate_repo(
|
||||
skip_git: bool = False,
|
||||
skip_issues: bool = False,
|
||||
skip_releases: bool = False,
|
||||
concurrency: int = 8,
|
||||
git_timeout: float = DEFAULT_GIT_TIMEOUT,
|
||||
) -> dict:
|
||||
"""Migrate one repo from source forge to target forge. Returns a report."""
|
||||
if not source_token or not target_token:
|
||||
@@ -153,20 +155,25 @@ def migrate_repo(
|
||||
source_token=source_token,
|
||||
target_token=target_token,
|
||||
workdir=workdir,
|
||||
git_timeout=git_timeout,
|
||||
)
|
||||
report["git"] = git_report
|
||||
log.info("git mirror done: %s", git_report)
|
||||
|
||||
if not skip_issues:
|
||||
label_id_map, _name_map = migrate_labels(src, tgt, owner, name)
|
||||
milestone_map = migrate_milestones(src, tgt, owner, name)
|
||||
migrate_issues_and_prs(src, tgt, owner, name, label_id_map, milestone_map, ref)
|
||||
label_id_map = migrate_labels(src, tgt, owner, name, concurrency=concurrency)
|
||||
milestone_map = migrate_milestones(src, tgt, owner, name, concurrency=concurrency)
|
||||
migrate_issues_and_prs(
|
||||
src, tgt, owner, name, label_id_map, milestone_map, ref, concurrency=concurrency
|
||||
)
|
||||
report["labels"] = len(label_id_map)
|
||||
report["milestones"] = len(milestone_map)
|
||||
report["issues_prs"] = len(numbers)
|
||||
|
||||
if not skip_releases:
|
||||
report["releases"] = migrate_releases(src, tgt, owner, name, ref)
|
||||
report["releases"] = migrate_releases(
|
||||
src, tgt, owner, name, ref, concurrency=concurrency
|
||||
)
|
||||
|
||||
log.info("migration complete: %s", report)
|
||||
return report
|
||||
Reference in new issue
Block a user