diff options
Diffstat (limited to 'lib/gitlab/badge/pipeline/status.rb')
-rw-r--r-- | lib/gitlab/badge/pipeline/status.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/gitlab/badge/pipeline/status.rb b/lib/gitlab/badge/pipeline/status.rb new file mode 100644 index 00000000000..5fee7a93475 --- /dev/null +++ b/lib/gitlab/badge/pipeline/status.rb @@ -0,0 +1,37 @@ +module Gitlab + module Badge + module Pipeline + ## + # Pipeline 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 + 'pipeline' + end + + def status + @project.pipelines + .where(sha: @sha) + .latest_status(@ref) || 'unknown' + end + + def metadata + @metadata ||= Pipeline::Metadata.new(self) + end + + def template + @template ||= Pipeline::Template.new(self) + end + end + end + end +end |