MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / extract_commit_hash

Function extract_commit_hash

diffusers/src/diffusers/utils/hub_utils.py:185–196  ·  view source on GitHub ↗

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

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

Source from the content-addressed store, hash-verified

183
184
185def extract_commit_hash(resolved_file: Optional[str], commit_hash: Optional[str] = None):
186 """
187 Extracts the commit hash from a resolved filename toward a cache file.
188 """
189 if resolved_file is None or commit_hash is not None:
190 return commit_hash
191 resolved_file = str(Path(resolved_file).as_posix())
192 search = re.search(r"snapshots/([^/]+)/", resolved_file)
193 if search is None:
194 return None
195 commit_hash = search.groups()[0]
196 return commit_hash if REGEX_COMMIT_HASH.match(commit_hash) else None
197
198
199# Old default cache path, potentially to be migrated.

Callers 1

load_configMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected