summaryrefslogtreecommitdiff
path: root/app/helpers/builds_helper.rb
blob: c247d3968ff42a040dca2ee5817fec47ac2aa06c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
module BuildsHelper
  def build_duration build
    if build.started?
      from = build.started_at
      to = build.finished_at || Time.now
      distance_of_time_in_words(from, to)
    end
  end

  def build_ref_link build
    if build.gitlab?
      gitlab_ref_link build.project, build.ref
    else
      build.ref
    end
  end

  def build_compare_link build
    if build.gitlab?
      gitlab_compare_link build.project, build.short_before_sha, build.short_sha
    end
  end

  def build_commit_link build
    if build.gitlab?
      gitlab_commit_link build.project, build.short_sha
    else
      build.short_sha
    end
  end

  def build_link build
    link_to(build.short_sha, project_build_path(build.project, build))
  end
end