summaryrefslogtreecommitdiff
path: root/lib/api/entities.rb
diff options
context:
space:
mode:
authorDylan Griffith <dyl.griffith@gmail.com>2018-05-03 09:54:12 +0200
committerDylan Griffith <dyl.griffith@gmail.com>2018-05-03 09:54:12 +0200
commitd39b3d4b8d2d4c5ded46182a5353c68a8f5bb5cd (patch)
treee8f2fac760b252928ff23074dea9d1f209838a33 /lib/api/entities.rb
parentdcb67951a817db262ddcd3b777fafc4e1995fc04 (diff)
parent2c9568edeea7d95b6e4ec3c23cdc1c027bf86d5f (diff)
downloadgitlab-ce-d39b3d4b8d2d4c5ded46182a5353c68a8f5bb5cd.tar.gz
Merge branch 'master' into feature/runner-per-group
Diffstat (limited to 'lib/api/entities.rb')
-rw-r--r--lib/api/entities.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index f28c4bcc784..6ff1c0624e5 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -291,6 +291,10 @@ module API
end
end
+ class DiffRefs < Grape::Entity
+ expose :base_sha, :head_sha, :start_sha
+ end
+
class Commit < Grape::Entity
expose :id, :short_id, :title, :created_at
expose :parent_ids
@@ -606,6 +610,8 @@ module API
merge_request.metrics&.pipeline
end
+ expose :diff_refs, using: Entities::DiffRefs
+
def build_available?(options)
options[:project]&.feature_available?(:builds, options[:current_user])
end
@@ -647,6 +653,11 @@ module API
expose :id, :key, :created_at
end
+ class DiffPosition < Grape::Entity
+ expose :base_sha, :start_sha, :head_sha, :old_path, :new_path,
+ :position_type
+ end
+
class Note < Grape::Entity
# Only Issue and MergeRequest have iid
NOTEABLE_TYPES_WITH_IID = %w(Issue MergeRequest).freeze
@@ -660,6 +671,14 @@ module API
expose :system?, as: :system
expose :noteable_id, :noteable_type
+ expose :position, if: ->(note, options) { note.diff_note? } do |note|
+ note.position.to_h
+ end
+
+ expose :resolvable?, as: :resolvable
+ expose :resolved?, as: :resolved, if: ->(note, options) { note.resolvable? }
+ expose :resolved_by, using: Entities::UserBasic, if: ->(note, options) { note.resolvable? }
+
# Avoid N+1 queries as much as possible
expose(:noteable_iid) { |note| note.noteable.iid if NOTEABLE_TYPES_WITH_IID.include?(note.noteable_type) }
end