MCPcopy Create free account
hub / github.com/MrNeRF/LichtFeld-Studio / prepare_github_archive

Function prepare_github_archive

src/python/lfs_plugins/installer.py:276–304  ·  view source on GitHub ↗

Download a GitHub repository archive into a staging directory.

(
    url: str,
    staging_parent: Path,
    on_progress: Optional[Callable[[str], None]] = None,
)

Source from the content-addressed store, hash-verified

274
275
276def prepare_github_archive(
277 url: str,
278 staging_parent: Path,
279 on_progress: Optional[Callable[[str], None]] = None,
280) -> tuple[Path, PluginSourceInfo]:
281 """Download a GitHub repository archive into a staging directory."""
282 owner, repo, ref = parse_github_url(url)
283 archive_url = github_archive_url(owner, repo, ref)
284
285 if on_progress:
286 ref_text = f"@{ref}" if ref else ""
287 on_progress(f"Downloading {owner}/{repo}{ref_text} archive...")
288
289 staging_dir = prepare_archive_from_download_url(
290 archive_url,
291 staging_parent,
292 temp_prefix=f".{repo}-",
293 request_headers={"Accept": "application/vnd.github+json"},
294 )
295 return staging_dir, PluginSourceInfo(
296 transport="archive",
297 origin=url.strip(),
298 github_url=github_repo_url(owner, repo),
299 owner=owner,
300 repo=repo,
301 requested_ref=ref or "",
302 resolved_ref=ref or "",
303 archive_url=archive_url,
304 )
305
306
307class PluginInstaller:

Calls 5

parse_github_urlFunction · 0.85
github_archive_urlFunction · 0.85
PluginSourceInfoClass · 0.85
github_repo_urlFunction · 0.85

Tested by

no test coverage detected