MCPcopy Create free account
hub / github.com/pollinations/pollinations / get_file_sha

Function get_file_sha

social/scripts/common.py:499–511  ·  view source on GitHub ↗

Get the SHA of an existing file

(github_token: str, owner: str, repo: str, file_path: str, branch: str = "main")

Source from the content-addressed store, hash-verified

497
498
499def get_file_sha(github_token: str, owner: str, repo: str, file_path: str, branch: str = "main") -> str:
500 """Get the SHA of an existing file"""
501 headers = _github_headers(github_token)
502
503 response = github_api_request(
504 "GET",
505 f"{GITHUB_API_BASE}/repos/{owner}/{repo}/contents/{file_path}?ref={branch}",
506 headers=headers,
507 )
508
509 if response.status_code == 200:
510 return response.json().get("sha", "")
511 return ""
512
513
514# ── Gist I/O helpers ─────────────────────────────────────────────────

Callers 4

commit_text_to_newsFunction · 0.90
commit_image_to_branchFunction · 0.85
commit_gistFunction · 0.85
commit_files_to_branchFunction · 0.85

Calls 4

_github_headersFunction · 0.85
github_api_requestFunction · 0.85
jsonMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected