INNER CODE UNIT · Python
_get_blob_sha
dotnet/sdk · .github/scripts/check_vendored_files.py:226
def _get_blob_sha(repo: str, ref: str, path: str) -> tuple[int, str | None]:
status, data = api_json(
f"/repos/{repo}/contents/{urllib.parse.quote(path)}?ref={urllib.parse.quote(ref, safe='/')}"
)
if status == 200 and isinstance(data, dict) and data.get("type") == "file":
return status, data.get("sha")
return status, None
def _truncate_diff(diff_lines: list[str], max_lines: int) -> str:
if len(diff_lines) <= max_lines:
return "".join(diff_lines)
head = "".join(diff_lines[:max_lines])
return f"{head}\n... (diff truncated; {len(diff_lines) - max_lines} more lines)"
def check_source(entry: Entry, source_index: int, source: Source) -> DriftResult:
status, current_blob_sha = _get_blob_sha(source.repo, source.ref, source.path)