diff options
author | James Lopez <james@jameslopez.es> | 2016-02-12 14:21:04 +0300 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2016-02-12 14:21:04 +0300 |
commit | a5b011c9d8586453d37852856822dab692f6613b (patch) | |
tree | f3400cff867007d9962e6fd31e0a94d460db1b88 /app/services | |
parent | 3753c1e03edb516033b4ef856aed63668de59cf3 (diff) | |
parent | b1dda8145433f15fcea683451c9c79927b19352e (diff) |
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into fix/cross-reference-notes-forks
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/ci/image_for_build_service.rb | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/app/services/ci/image_for_build_service.rb b/app/services/ci/image_for_build_service.rb index f469b13e902..005a5c4661c 100644 --- a/app/services/ci/image_for_build_service.rb +++ b/app/services/ci/image_for_build_service.rb @@ -1,28 +1,23 @@ module Ci class ImageForBuildService - def execute(project, params) - sha = params[:sha] - sha ||= - if params[:ref] - project.commit(params[:ref]).try(:sha) - end + def execute(project, opts) + sha = opts[:sha] || ref_sha(project, opts[:ref]) commit = project.ci_commits.ordered.find_by(sha: sha) image_name = image_for_commit(commit) image_path = Rails.root.join('public/ci', image_name) - - OpenStruct.new( - path: image_path, - name: image_name - ) + OpenStruct.new(path: image_path, name: image_name) end private + def ref_sha(project, ref) + project.commit(ref).try(:sha) if ref + end + def image_for_commit(commit) return 'build-unknown.svg' unless commit - 'build-' + commit.status + ".svg" end end |