INNER CODE UNIT · Python
github_headers
epigen/MrBiomics · helpers/MrBiomics_context_crawler.py:98
def github_headers(token: Optional[str]) -> dict[str, str]:
headers = {
"Accept": "application/vnd.github+json",
"User-Agent": "MrBiomics-context-crawler",
}
if token:
headers["Authorization"] = f"Bearer {token}"
return headers
def fetch_latest_commit(repo_url: str, token: Optional[str] = None) -> tuple[str, str]:
"""Use the GitHub API to look up the default-branch commit for a normal repo."""
repo_id = repo_identifier(repo_url)
if not repo_id:
raise RuntimeError(f"Unable to parse repository identifier from {repo_url}")
session = requests.Session()
session.headers.update(github_headers(token))
try: