BigW Consortium Gitlab

graph_helper.rb 850 Bytes
Newer Older
1
module GraphHelper
2
  def get_refs(repo, commit)
3
    refs = ""
4 5 6 7
    # Commit::ref_names already strips the refs/XXX from important refs (e.g. refs/heads/XXX)
    # so anything leftover is internally used by GitLab
    commit_refs = commit.ref_names(repo).reject{ |name| name.starts_with?('refs/') }
    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 22 23 24 25 26 27 28

  def success_ratio(success_builds, failed_builds)
    failed_builds = failed_builds.count(:all)
    success_builds = success_builds.count(:all)

    return 100 if failed_builds.zero?

    ratio = (success_builds.to_f / (success_builds + failed_builds)) * 100
    ratio.to_i
  end
29
end