MCPcopy Create free account
hub / github.com/base/base / resolve_reference

Function resolve_reference

etc/scripts/local/pin-reth.py:374–398  ·  view source on GitHub ↗

Resolve `reference` to a full commit SHA with `git ls-remote`.

(repository: str, reference: str)

Source from the content-addressed store, hash-verified

372
373
374def resolve_reference(repository: str, reference: str) -> str:
375 """Resolve `reference` to a full commit SHA with `git ls-remote`."""
376 if is_full_sha(reference):
377 return reference.lower()
378 result = subprocess.run(
379 [
380 "git",
381 "ls-remote",
382 repository,
383 f"refs/tags/{reference}",
384 f"refs/tags/{reference}^{{}}",
385 f"refs/heads/{reference}",
386 ],
387 capture_output=True,
388 text=True,
389 check=False,
390 )
391 if result.returncode != 0:
392 raise PinError(
393 f"git ls-remote {repository} {reference} failed: {result.stderr.strip()}"
394 )
395 try:
396 return commit_from_ls_remote(result.stdout, reference)
397 except PinError as exc:
398 raise PinError(f"could not resolve {reference} on {repository}") from exc
399
400
401def run_cargo(root: Path, args: list[str]) -> None:

Callers 2

apply_pinFunction · 0.85
check_pinFunction · 0.85

Calls 4

is_full_shaFunction · 0.85
PinErrorClass · 0.85
commit_from_ls_remoteFunction · 0.85
runMethod · 0.45

Tested by

no test coverage detected