Welcome to mirror list, hosted at ThFree Co, Russian Federation.

status.rb « build « badge « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3c65fd02e4cbad4a613b8b38bfa7505012fee572 (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
36
37
module Gitlab
  module Badge
    module Build
      ##
      # Build status badge
      #
      class Status < Badge::Base
        attr_reader :project, :ref

        def initialize(project, ref)
          @project = project
          @ref = ref

          @sha = @project.commit(@ref).try(:sha)
        end

        def entity
          'build'
        end

        def status
          @project.pipelines.
            where(sha: @sha).
            latest_status(@ref) || 'unknown'
        end

        def metadata
          @metadata ||= Build::Metadata.new(self)
        end

        def template
          @template ||= Build::Template.new(self)
        end
      end
    end
  end
end