INNER CODE UNIT · Python
fetch_blob_content
dotnet/sdk · .github/scripts/check_vendored_files.py:185
def fetch_blob_content(repo: str, blob_sha: str) -> str | None:
status, data = api_json(f"/repos/{repo}/git/blobs/{blob_sha}")
if status != 200 or not isinstance(data, dict):
return None
if data.get("encoding") != "base64":
return None
try:
return base64.b64decode(data["content"]).decode("utf-8", errors="replace")
except (KeyError, ValueError):
return None
def fetch_raw(repo: str, ref: str, path: str) -> str | None:
url = f"{RAW_BASE}/{repo}/{ref}/{urllib.parse.quote(path)}"
status, body, _ = _request(url, accept="text/plain")
if status != 200:
return None
return body.decode("utf-8", errors="replace")