Resolve the current `HEAD` commit SHA, filesystem-first. Args: path: Directory or file path inside a repository. Returns: The full commit SHA, or an empty string when none can be determined.
(path: str | Path)
| 355 | |
| 356 | |
| 357 | def resolve_git_commit_sha(path: str | Path) -> str: |
| 358 | """Resolve the current `HEAD` commit SHA, filesystem-first. |
| 359 | |
| 360 | Args: |
| 361 | path: Directory or file path inside a repository. |
| 362 | |
| 363 | Returns: |
| 364 | The full commit SHA, or an empty string when none can be determined. |
| 365 | """ |
| 366 | sha = read_git_commit_sha_from_filesystem(path) |
| 367 | if sha is not None: |
| 368 | return sha |
| 369 | return read_git_commit_sha_via_subprocess(path) |
| 370 | |
| 371 | |
| 372 | def read_git_remote_url_from_filesystem(path: str | Path) -> str | None: |