diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-07-05 13:18:53 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-07-05 13:18:53 +0300 |
commit | fe695ebd24e59f82d16aba629dd6d117be3ee5bb (patch) | |
tree | d983a8079fc7c8f3f9e2f62642c769a4a312613d /app/serializers | |
parent | 82967557aa596e762512502c4d1d0803806cc2fd (diff) | |
parent | 590ffa957ff79168a844ab56ea4070d7b21f5422 (diff) |
Merge branch 'issue_48474' into 'master'
Fix discussion entity for legacy diff notes
Closes #48474
See merge request gitlab-org/gitlab-ce!20214
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/diff_file_entity.rb | 5 | ||||
-rw-r--r-- | app/serializers/discussion_entity.rb | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/app/serializers/diff_file_entity.rb b/app/serializers/diff_file_entity.rb index aa289a96975..61135fba97b 100644 --- a/app/serializers/diff_file_entity.rb +++ b/app/serializers/diff_file_entity.rb @@ -25,6 +25,8 @@ class DiffFileEntity < Grape::Entity expose :can_modify_blob do |diff_file| merge_request = options[:merge_request] + next unless diff_file.blob + if merge_request&.source_project && current_user can_modify_blob?(diff_file.blob, merge_request.source_project, merge_request.source_branch) else @@ -108,6 +110,7 @@ class DiffFileEntity < Grape::Entity project = merge_request.target_project next unless project + next unless diff_file.content_sha project_blob_path(project, tree_join(diff_file.content_sha, diff_file.new_path)) end @@ -125,6 +128,8 @@ class DiffFileEntity < Grape::Entity end expose :context_lines_path, if: -> (diff_file, _) { diff_file.text? } do |diff_file| + next unless diff_file.content_sha + project_blob_diff_path(diff_file.repository.project, tree_join(diff_file.content_sha, diff_file.file_path)) end diff --git a/app/serializers/discussion_entity.rb b/app/serializers/discussion_entity.rb index 63f28133a64..8a39a4950f5 100644 --- a/app/serializers/discussion_entity.rb +++ b/app/serializers/discussion_entity.rb @@ -3,7 +3,7 @@ class DiscussionEntity < Grape::Entity include NotesHelper expose :id, :reply_id - expose :position, if: -> (d, _) { d.diff_discussion? } + expose :position, if: -> (d, _) { d.diff_discussion? && !d.legacy_diff_discussion? } expose :line_code, if: -> (d, _) { d.diff_discussion? } expose :expanded?, as: :expanded expose :active?, as: :active, if: -> (d, _) { d.diff_discussion? } |