class Dependabot::PullRequestCreator::MessageBuilder::MetadataPresenter

def commits_cascade

def commits_cascade
  return "" unless commits_url && commits
  msg = ""
  commits.last(10).reverse_each do |commit|
    title = commit[:message].strip.split("\n").first
    title = title.slice(0..76) + "..." if title && title.length > 80
    title = title&.gsub(/(?<=[^\w.-])([_*`~])/, '\\1')
    sha = commit[:sha][0, 7]
    msg += "- [`#{sha}`](#{commit[:html_url]}) #{title}\n"
  end
  msg = msg.gsub(/\<.*?\>/) { |tag| "\\#{tag}" }
  msg +=
    if commits.count > 10
      "- Additional commits viewable in " \
        "[compare view](#{commits_url})\n"
    else
      "- See full diff in [compare view](#{commits_url})\n"
    end
  msg = link_issues(text: msg)
  msg = sanitize_links_and_mentions(msg)
  build_details_tag(summary: "Commits", body: msg)
end