MCPcopy Create free account
hub / github.com/idank/explainshell / _resolve_mandoc_version_cached

Function _resolve_mandoc_version_cached

explainshell/extraction/common.py:90–102  ·  view source on GitHub ↗
(
    abs_path: str, _mtime_size: tuple[float, int]
)

Source from the content-addressed store, hash-verified

88
89@functools.lru_cache(maxsize=8)
90def _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
105def resolve_mandoc_version(binary_path: str) -> str | None:

Callers 1

resolve_mandoc_versionFunction · 0.85

Calls 2

_git_runFunction · 0.85
_file_sha256_prefixFunction · 0.85

Tested by

no test coverage detected