2013-03-06 06:31:28 -05:00
|
|
|
module GraphHelper
|
2013-08-19 23:05:23 -04:00
|
|
|
def get_refs(repo, commit)
|
2013-03-25 20:51:39 -04:00
|
|
|
refs = ""
|
2015-09-23 11:21:51 -04:00
|
|
|
# Commit::ref_names already strips the refs/XXX from important refs (e.g. refs/heads/XXX)
|
|
|
|
# so anything leftover is internally used by GitLab
|
2017-08-09 05:52:22 -04:00
|
|
|
commit_refs = commit.ref_names(repo).reject { |name| name.starts_with?('refs/') }
|
2015-09-23 11:21:51 -04:00
|
|
|
refs << commit_refs.join(' ')
|
2013-03-25 20:51:39 -04:00
|
|
|
|
|
|
|
# append note count
|
2014-10-09 03:47:47 -04:00
|
|
|
refs << "[#{@graph.notes[commit.id]}]" if @graph.notes[commit.id] > 0
|
2013-03-25 20:51:39 -04:00
|
|
|
|
|
|
|
refs
|
2013-03-06 06:31:28 -05:00
|
|
|
end
|
2013-03-06 07:01:40 -05:00
|
|
|
|
|
|
|
def parents_zip_spaces(parents, parent_spaces)
|
|
|
|
ids = parents.map { |p| p.id }
|
|
|
|
ids.zip(parent_spaces)
|
|
|
|
end
|
2015-12-04 06:55:23 -05:00
|
|
|
|
2017-06-23 06:18:52 -04:00
|
|
|
def success_ratio(counts)
|
|
|
|
return 100 if counts[:failed].zero?
|
2015-12-04 06:55:23 -05:00
|
|
|
|
2017-06-23 06:18:52 -04:00
|
|
|
ratio = (counts[:success].to_f / (counts[:success] + counts[:failed])) * 100
|
2015-12-04 06:55:23 -05:00
|
|
|
ratio.to_i
|
|
|
|
end
|
2013-03-06 06:31:28 -05:00
|
|
|
end
|