blob: 17f179f027d7de9d287c9088fd14b6c073fe0d68 (
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
38
39
40
41
42
43
44
45
|
# frozen_string_literal: true
module Gitlab
module Badge
module Pipeline
##
# Pipeline status badge
#
class Status < Badge::Base
attr_reader :project, :ref, :customization
def initialize(project, ref, opts: {})
@project = project
@ref = ref
@customization = {
key_width: opts[:key_width].to_i,
key_text: opts[:key_text]
}
@sha = @project.commit(@ref).try(:sha)
end
def entity
'pipeline'
end
# rubocop: disable CodeReuse/ActiveRecord
def status
@project.ci_pipelines
.where(sha: @sha)
.latest_status(@ref) || 'unknown'
end
# rubocop: enable CodeReuse/ActiveRecord
def metadata
@metadata ||= Pipeline::Metadata.new(self)
end
def template
@template ||= Pipeline::Template.new(self)
end
end
end
end
end
|