Commit 5c2892bf authored by Robert Speicher's avatar Robert Speicher Committed by Robert Speicher

Merge branch 'fix-ci-badge' into 'master'

Fix CI badge

The previous code relied on having on ref stored in commit, however the ref was moved to the build.

Fixes #3104

See merge request !1690
parent bdfd23ee
...@@ -7,6 +7,7 @@ v 8.1.1 ...@@ -7,6 +7,7 @@ v 8.1.1
- Fix 500 when editing CI service - Fix 500 when editing CI service
- Require CI jobs to be named - Require CI jobs to be named
- Fix CSS for runner status - Fix CSS for runner status
- Fix CI badge
v 8.1.0 v 8.1.0
- Ensure MySQL CI limits DB migrations occur after the fields have been created (Stan Hu) - Ensure MySQL CI limits DB migrations occur after the fields have been created (Stan Hu)
...@@ -19,6 +20,7 @@ v 8.1.0 ...@@ -19,6 +20,7 @@ v 8.1.0
- Don't show "Add README" link in an empty repository if user doesn't have access to push (Stan Hu) - Don't show "Add README" link in an empty repository if user doesn't have access to push (Stan Hu)
- Fix error preventing displaying of commit data for a directory with a leading dot (Stan Hu) - Fix error preventing displaying of commit data for a directory with a leading dot (Stan Hu)
- Speed up load times of issue detail pages by roughly 1.5x - Speed up load times of issue detail pages by roughly 1.5x
- Require CI jobs to be named
- Fix CI rendering regressions - Fix CI rendering regressions
- Allow developer to manage builds - Allow developer to manage builds
- If a merge request is to close an issue, show this on the issue page (Zeger-Jan van de Weg) - If a merge request is to close an issue, show this on the issue page (Zeger-Jan van de Weg)
......
...@@ -27,9 +27,5 @@ module Ci ...@@ -27,9 +27,5 @@ module Ci
def human_status def human_status
status status
end end
def last_commit_for_ref(ref)
commits.where(ref: ref).last
end
end end
end end
module Ci module Ci
class ImageForBuildService class ImageForBuildService
def execute(project, params) def execute(project, params)
image_name = sha = params[:sha]
if params[:sha] sha ||=
commit = project.commits.find_by(sha: params[:sha]) if params[:ref]
image_for_commit(commit) project.gl_project.commit(params[:ref]).try(:sha)
elsif params[:ref]
commit = project.last_commit_for_ref(params[:ref])
image_for_commit(commit)
else
'build-unknown.svg'
end end
commit = project.commits.ordered.find_by(sha: sha)
image_name = image_for_commit(commit)
image_path = Rails.root.join('public/ci', image_name) image_path = Rails.root.join('public/ci', image_name)
OpenStruct.new( OpenStruct.new(
......
...@@ -4,8 +4,9 @@ module Ci ...@@ -4,8 +4,9 @@ module Ci
describe ImageForBuildService do describe ImageForBuildService do
let(:service) { ImageForBuildService.new } let(:service) { ImageForBuildService.new }
let(:project) { FactoryGirl.create(:ci_project) } let(:project) { FactoryGirl.create(:ci_project) }
let(:gl_project) { FactoryGirl.create(:empty_project, gitlab_ci_project: project) } let(:gl_project) { FactoryGirl.create(:project, gitlab_ci_project: project) }
let(:commit) { FactoryGirl.create(:ci_commit, gl_project: gl_project, ref: 'master') } let(:commit_sha) { gl_project.commit('master').sha }
let(:commit) { gl_project.ensure_ci_commit(commit_sha) }
let(:build) { FactoryGirl.create(:ci_build, commit: commit) } let(:build) { FactoryGirl.create(:ci_build, commit: commit) }
describe :execute do describe :execute do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment