diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb index 21f4d9f44ecf2270dbc83871ab473ffe350db96c..637a911177c13cfc0fe75e4b74dc6dd43c379171 100644 --- a/app/controllers/projects/commit_controller.rb +++ b/app/controllers/projects/commit_controller.rb @@ -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 diff --git a/config/routes.rb b/config/routes.rb index 3f6561a1fe0ee6bd63fe2a2a6acc437a74bd0c75..30e42e197f4b252d6db2b68d5acd8f20953907a1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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]