2014-09-02 18:07:02 +05:30
|
|
|
module GraphHelper
|
|
|
|
def get_refs(repo, commit)
|
|
|
|
refs = ""
|
2015-09-25 12:07:36 +05:30
|
|
|
# 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(' ')
|
2014-09-02 18:07:02 +05:30
|
|
|
|
|
|
|
# append note count
|
2015-04-26 12:48:37 +05:30
|
|
|
refs << "[#{@graph.notes[commit.id]}]" if @graph.notes[commit.id] > 0
|
2014-09-02 18:07:02 +05:30
|
|
|
|
|
|
|
refs
|
|
|
|
end
|
|
|
|
|
|
|
|
def parents_zip_spaces(parents, parent_spaces)
|
|
|
|
ids = parents.map { |p| p.id }
|
|
|
|
ids.zip(parent_spaces)
|
|
|
|
end
|
2015-12-23 02:04:40 +05:30
|
|
|
|
|
|
|
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
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|