summaryrefslogtreecommitdiff
path: root/app/serializers
diff options
context:
space:
mode:
authorFatih Acet <acetfatih@gmail.com>2018-10-04 11:37:33 +0000
committerFatih Acet <acetfatih@gmail.com>2018-10-04 11:37:33 +0000
commitd7a3ccb4ce0d511e8221aa6573e708b976c8d135 (patch)
tree9cfd99d36cd602212588ab60e62e4b402d80f3c1 /app/serializers
parent22de07ac7be03f01f08f6b72bbdbd1123bd8f637 (diff)
parentbecb86ea4e8032788b151caac004b2635b57c6a4 (diff)
downloadgitlab-ce-d7a3ccb4ce0d511e8221aa6573e708b976c8d135.tar.gz
Merge branch '49329-mr-show-commit-details' into 'master'
Add signature badge and pipeline status to commit details in MR diff Closes #49329 See merge request gitlab-org/gitlab-ce!22079
Diffstat (limited to 'app/serializers')
-rw-r--r--app/serializers/commit_entity.rb21
-rw-r--r--app/serializers/diffs_entity.rb4
2 files changed, 24 insertions, 1 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/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