Extracts the commit hash from a resolved filename toward a cache file.
(resolved_file: Optional[str], commit_hash: Optional[str])
| 217 | |
| 218 | |
| 219 | def extract_commit_hash(resolved_file: Optional[str], commit_hash: Optional[str]): |
| 220 | """ |
| 221 | Extracts the commit hash from a resolved filename toward a cache file. |
| 222 | """ |
| 223 | if resolved_file is None or commit_hash is not None: |
| 224 | return commit_hash |
| 225 | resolved_file = str(Path(resolved_file).as_posix()) |
| 226 | search = re.search(r"snapshots/([^/]+)/", resolved_file) |
| 227 | if search is None: |
| 228 | return None |
| 229 | commit_hash = search.groups()[0] |
| 230 | return commit_hash if REGEX_COMMIT_HASH.match(commit_hash) else None |
| 231 | |
| 232 | |
| 233 | def try_to_load_from_cache( |
nothing calls this directly
no outgoing calls
no test coverage detected