Method: Transformers::Utils::Hub.extract_commit_hash
- Defined in:
- lib/transformers/utils/hub.rb
.extract_commit_hash(resolved_file, commit_hash) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/transformers/utils/hub.rb', line 46 def extract_commit_hash(resolved_file, commit_hash) if resolved_file.nil? || !commit_hash.nil? return commit_hash end search = /snapshots\/([^\/]+)/.match(resolved_file) if search.nil? return nil end commit_hash = search[1] HfHub::REGEX_COMMIT_HASH.match(commit_hash) ? commit_hash : nil end |