(
abs_path: str, _mtime_size: tuple[float, int]
)
| 88 | |
| 89 | @functools.lru_cache(maxsize=8) |
| 90 | def _resolve_mandoc_version_cached( |
| 91 | abs_path: str, _mtime_size: tuple[float, int] |
| 92 | ) -> str: |
| 93 | if Path(abs_path) == _TRACKED_MANDOC: |
| 94 | # `git diff --quiet` returns 1 when there are working-tree changes. |
| 95 | dirty = _git_run(["diff", "--quiet", "HEAD", "--", "tools/mandoc-md"]) |
| 96 | if dirty.returncode == 0: |
| 97 | log = _git_run(["log", "-1", "--format=%h", "--", "tools/mandoc-md"]) |
| 98 | sha = log.stdout.strip() |
| 99 | if sha: |
| 100 | return f"repo:{sha}" |
| 101 | return f"repo:dirty:{_file_sha256_prefix(abs_path)}" |
| 102 | return f"custom:{_file_sha256_prefix(abs_path)}" |
| 103 | |
| 104 | |
| 105 | def resolve_mandoc_version(binary_path: str) -> str | None: |
no test coverage detected