diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-10-05 04:13:06 +0300 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-10-05 04:13:06 +0300 |
commit | af2c51d7ca73e16cdb9a11fff6d097116c7c5324 (patch) | |
tree | cd7f07f36e09a357902a262cbb932f25d254a16c /app/serializers | |
parent | acfe7ec65c75f65f2f87bf3e8598c1725c9150f4 (diff) | |
parent | f71c497f5da791a35876206255e342a9bb5e49c5 (diff) |
Merge branch 'master-ce' into scheduled-manual-jobs
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/commit_entity.rb | 21 | ||||
-rw-r--r-- | app/serializers/detailed_status_entity.rb | 8 | ||||
-rw-r--r-- | app/serializers/diffs_entity.rb | 4 |
3 files changed, 31 insertions, 2 deletions
diff --git a/app/serializers/commit_entity.rb b/app/serializers/commit_entity.rb index 396e95a03c8..a94e32478ce 100644 --- a/app/serializers/commit_entity.rb +++ b/app/serializers/commit_entity.rb @@ -25,4 +25,25 @@ class CommitEntity < API::Entities::Commit expose :title_html, if: { type: :full } do |commit| markdown_field(commit, :title) end + + expose :signature_html, if: { type: :full } do |commit| + render('projects/commit/_signature', signature: commit.signature) if commit.has_signature? + end + + expose :pipeline_status_path, if: { type: :full } do |commit, options| + pipeline_ref = options[:pipeline_ref] + pipeline_project = options[:pipeline_project] || commit.project + next unless pipeline_ref && pipeline_project + + status = commit.status_for_project(pipeline_ref, pipeline_project) + next unless status + + pipelines_project_commit_path(pipeline_project, commit.id, ref: pipeline_ref) + end + + def render(*args) + return unless request.respond_to?(:render) && request.render.respond_to?(:call) + + request.render.call(*args) + end end diff --git a/app/serializers/detailed_status_entity.rb b/app/serializers/detailed_status_entity.rb index c772c807f76..da994d78286 100644 --- a/app/serializers/detailed_status_entity.rb +++ b/app/serializers/detailed_status_entity.rb @@ -10,7 +10,12 @@ class DetailedStatusEntity < Grape::Entity expose :illustration do |status| begin - status.illustration + illustration = { + image: ActionController::Base.helpers.image_path(status.illustration[:image]) + } + illustration = status.illustration.merge(illustration) + + illustration rescue NotImplementedError # ignored end @@ -25,5 +30,6 @@ class DetailedStatusEntity < Grape::Entity expose :action_title, as: :title expose :action_path, as: :path expose :action_method, as: :method + expose :action_button_title, as: :button_title end end diff --git a/app/serializers/diffs_entity.rb b/app/serializers/diffs_entity.rb index 00dc55fc004..b51e4a7e6d0 100644 --- a/app/serializers/diffs_entity.rb +++ b/app/serializers/diffs_entity.rb @@ -18,7 +18,9 @@ class DiffsEntity < Grape::Entity expose :commit do |diffs, options| CommitEntity.represent options[:commit], options.merge( type: :full, - commit_url_params: { merge_request_iid: merge_request&.iid } + commit_url_params: { merge_request_iid: merge_request&.iid }, + pipeline_ref: merge_request&.source_branch, + pipeline_project: merge_request&.source_project ) end |