diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 11:18:50 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 11:18:50 +0000 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /app/serializers/diffs_entity.rb | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) | |
download | gitlab-ce-8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781.tar.gz |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'app/serializers/diffs_entity.rb')
-rw-r--r-- | app/serializers/diffs_entity.rb | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/app/serializers/diffs_entity.rb b/app/serializers/diffs_entity.rb index fb4fbe57130..6ef524b5bec 100644 --- a/app/serializers/diffs_entity.rb +++ b/app/serializers/diffs_entity.rb @@ -69,19 +69,17 @@ class DiffsEntity < Grape::Entity expose :diff_files do |diffs, options| submodule_links = Gitlab::SubmoduleLinks.new(merge_request.project.repository) - code_navigation_path = - Gitlab::CodeNavigationPath.new(merge_request.project, diffs.diff_refs.head_sha) DiffFileEntity.represent(diffs.diff_files, - options.merge(submodule_links: submodule_links, code_navigation_path: code_navigation_path)) + options.merge(submodule_links: submodule_links, code_navigation_path: code_navigation_path(diffs))) end expose :merge_request_diffs, using: MergeRequestDiffEntity, if: -> (_, options) { options[:merge_request_diffs]&.any? } do |diffs| options[:merge_request_diffs] end - expose :definition_path_prefix, if: -> (diff_file) { Feature.enabled?(:code_navigation, merge_request.project) } do |diffs| - project_blob_path(merge_request.project, diffs.diff_refs.head_sha) + expose :definition_path_prefix, if: -> (diff_file) { Feature.enabled?(:code_navigation, merge_request.project, default_enabled: true) } do |diffs| + project_blob_path(merge_request.project, diffs.diff_refs&.head_sha) end def merge_request @@ -90,6 +88,12 @@ class DiffsEntity < Grape::Entity private + def code_navigation_path(diffs) + return unless Feature.enabled?(:code_navigation, merge_request.project, default_enabled: true) + + Gitlab::CodeNavigationPath.new(merge_request.project, diffs.diff_refs&.head_sha) + end + def commit_ids @commit_ids ||= merge_request.recent_commits.map(&:id) end |