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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-07-28 15:58:53 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-07-28 15:58:53 +0300
commit0c4fa8619ca477c0a78c825df8dd38cd2a109644 (patch)
treec48ff9bd346e8135542eb2ee2f246de899d20ae3 /lib/gitlab/badge
parent9ae1ecf876e40ce9dd64c72e025f32e38c882fd6 (diff)
Calculate build status only in build badge class
Diffstat (limited to 'lib/gitlab/badge')
-rw-r--r--lib/gitlab/badge/build.rb20
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/gitlab/badge/build.rb b/lib/gitlab/badge/build.rb
index 21d60854bf5..7bc6f285ce1 100644
--- a/lib/gitlab/badge/build.rb
+++ b/lib/gitlab/badge/build.rb
@@ -5,8 +5,16 @@ module Gitlab
#
class Build
def initialize(project, ref)
- @project, @ref = project, ref
- @image = ::Ci::ImageForBuildService.new.execute(project, ref: ref)
+ @project = project
+ @ref = ref
+ end
+
+ def status
+ sha = @project.commit(@ref).try(:sha)
+
+ @project.pipelines
+ .where(sha: sha, ref: @ref)
+ .status || 'unknown'
end
def metadata
@@ -18,11 +26,9 @@ module Gitlab
end
def data
- File.read(@image[:path])
- end
-
- def to_s
- @image[:name].sub(/\.svg$/, '')
+ File.read(
+ Rails.root.join('public/ci', 'build-' + status + '.svg')
+ )
end
end
end