Get the SHA of an existing file
(github_token: str, owner: str, repo: str, file_path: str, branch: str = "main")
| 497 | |
| 498 | |
| 499 | def 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 ───────────────────────────────────────────────── |
no test coverage detected