2016-08-10 08:12:31 -04:00
|
|
|
module Gitlab
|
|
|
|
module Badge
|
2017-07-19 07:08:47 -04:00
|
|
|
module Pipeline
|
2016-08-10 08:12:31 -04:00
|
|
|
##
|
2017-07-19 07:08:47 -04:00
|
|
|
# Pipeline status badge
|
2016-08-10 08:12:31 -04:00
|
|
|
#
|
|
|
|
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
|
2017-07-19 07:08:47 -04:00
|
|
|
'pipeline'
|
2016-08-11 05:16:14 -04:00
|
|
|
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
|
2017-07-19 07:08:47 -04:00
|
|
|
@metadata ||= Pipeline::Metadata.new(self)
|
2016-08-10 08:12:31 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def template
|
2017-07-19 07:08:47 -04:00
|
|
|
@template ||= Pipeline::Template.new(self)
|
2016-08-10 08:12:31 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|