2016-08-10 08:12:31 -04:00
|
|
|
module Gitlab
|
|
|
|
module Badge
|
|
|
|
module Build
|
|
|
|
##
|
|
|
|
# Build status badge
|
|
|
|
#
|
|
|
|
class Status < Badge::Base
|
2016-08-11 05:16:14 -04:00
|
|
|
attr_reader :project, :ref
|
2016-08-10 08:12:31 -04:00
|
|
|
|
|
|
|
def initialize(project, ref)
|
|
|
|
@project = project
|
|
|
|
@ref = ref
|
2016-08-11 05:16:14 -04:00
|
|
|
|
2016-08-10 08:12:31 -04:00
|
|
|
@sha = @project.commit(@ref).try(:sha)
|
|
|
|
end
|
|
|
|
|
2016-08-11 05:16:14 -04:00
|
|
|
def entity
|
|
|
|
'build'
|
|
|
|
end
|
|
|
|
|
2016-08-10 08:12:31 -04:00
|
|
|
def status
|
|
|
|
@project.pipelines
|
2016-11-24 04:00:37 -05:00
|
|
|
.where(sha: @sha)
|
2016-12-15 05:12:33 -05:00
|
|
|
.latest_status(@ref) || 'unknown'
|
2016-08-10 08:12:31 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def metadata
|
2016-08-11 05:16:14 -04:00
|
|
|
@metadata ||= Build::Metadata.new(self)
|
2016-08-10 08:12:31 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def template
|
2016-08-11 05:16:14 -04:00
|
|
|
@template ||= Build::Template.new(self)
|
2016-08-10 08:12:31 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|