INNER CODE UNIT · Python

fetch_latest_commit

epigen/MrBiomics · helpers/MrBiomics_context_crawler.py:108

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:
      repo_resp = session.get(f"https://api.github.com/repos/{repo_id}", timeout=30)
      repo_resp.raise_for_status()
      default_branch = repo_resp.json().get("default_branch", "main")
      commit_resp = session.get(
          f"https://api.github.com/repos/{repo_id}/commits/{default_branch}",
          timeout=30,
      )
      commit_resp.raise_for_status()
      data = commit_resp.json()
  except requests.HTTPError as exc:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…