graph_helper.rb 741 Bytes
Newer Older
1
module GraphHelper
2
  def get_refs(repo, commit)
3
    refs = ""
4 5
    # Commit::ref_names already strips the refs/XXX from important refs (e.g. refs/heads/XXX)
    # so anything leftover is internally used by GitLab
6
    commit_refs = commit.ref_names(repo).reject { |name| name.starts_with?('refs/') }
7
    refs << commit_refs.join(' ')
8 9

    # append note count
10
    refs << "[#{@graph.notes[commit.id]}]" if @graph.notes[commit.id] > 0
11 12

    refs
13
  end
14 15 16 17 18

  def parents_zip_spaces(parents, parent_spaces)
    ids = parents.map { |p| p.id }
    ids.zip(parent_spaces)
  end
19

20 21
  def success_ratio(counts)
    return 100 if counts[:failed].zero?
22

23
    ratio = (counts[:success].to_f / (counts[:success] + counts[:failed])) * 100
24 25
    ratio.to_i
  end
26
end