class Dependabot::GitMetadataFetcher
def parse_refs_for_upload_pack
def parse_refs_for_upload_pack peeled_lines = [] result = T.must(upload_pack).lines.each_with_object({}) do |line, res| full_ref_name = T.must(line.split.last) next unless full_ref_name.start_with?("refs/tags", "refs/heads") (peeled_lines << line) && next if line.strip.end_with?("^{}") ref_name = full_ref_name.sub(%r{^refs/(tags|heads)/}, "").strip sha = sha_for_update_pack_line(line) res[ref_name] = GitRef.new( name: ref_name, ref_sha: sha, ref_type: full_ref_name.start_with?("refs/tags") ? RefType::Tag : RefType::Head, commit_sha: sha ) end # Loop through the peeled lines, updating the commit_sha for any # matching tags in our results hash peeled_lines.each do |line| ref_name = line.split(%r{ refs/(tags|heads)/}) .last.strip.gsub(/\^{}$/, "") next unless result[ref_name] result[ref_name].commit_sha = sha_for_update_pack_line(line) end result.values end