Add CI status badge implementation to commit controller

This commit is contained in:
Grzegorz Bizon 2016-02-05 12:38:10 +01:00
parent 01a406f5b0
commit 14f928b730
2 changed files with 13 additions and 0 deletions

View File

@ -57,6 +57,12 @@ class Projects::CommitController < Projects::ApplicationController
render layout: false
end
def status
status_sha = ci_commit.sha if ci_commit
image = Ci::ImageForBuildService.new.execute(@project, sha: status_sha)
send_file(image.path, filename: image.name, disposition: 'inline', type: 'image/svg+xml')
end
private
def commit

View File

@ -493,6 +493,13 @@ Rails.application.routes.draw do
constraints: { id: /(?:[^.]|\.(?!atom$))+/, format: /atom/ },
as: :commits
)
get(
'/status/*id/badge',
to: 'commit#status',
constraints: { format: /png/ },
as: :commit_status
)
end
resource :avatar, only: [:show, :destroy]