MCPcopy Create free account
hub / github.com/TheLastBen/fast-stable-diffusion / extract_commit_hash

Function extract_commit_hash

Dreambooth/hub.py:219–230  ·  view source on GitHub ↗

Extracts the commit hash from a resolved filename toward a cache file.

(resolved_file: Optional[str], commit_hash: Optional[str])

Source from the content-addressed store, hash-verified

217
218
219def 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
233def try_to_load_from_cache(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected