Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-02 12:08:14 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-02 12:08:14 +0300
commitade18c9d68d5a2e6c6e28ef7e9d3add3b3491ace (patch)
treecf4154332fc95283f58cccb1383e43b40485d91d /app/serializers
parentba836d98593d68d8d6c22c540e31c8031a786bd8 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/serializers')
-rw-r--r--app/serializers/diff_file_entity.rb4
-rw-r--r--app/serializers/diffs_entity.rb10
-rw-r--r--app/serializers/paginated_diff_entity.rb6
3 files changed, 18 insertions, 2 deletions
diff --git a/app/serializers/diff_file_entity.rb b/app/serializers/diff_file_entity.rb
index 45c16aabe9e..26a42d2e9eb 100644
--- a/app/serializers/diff_file_entity.rb
+++ b/app/serializers/diff_file_entity.rb
@@ -64,6 +64,10 @@ class DiffFileEntity < DiffFileBaseEntity
# Used for parallel diffs
expose :parallel_diff_lines, using: DiffLineParallelEntity, if: -> (diff_file, options) { parallel_diff_view?(options, diff_file) && diff_file.text? }
+ expose :code_navigation_path, if: -> (diff_file) { options[:code_navigation_path] } do |diff_file|
+ options[:code_navigation_path].full_json_path_for(diff_file.new_path)
+ end
+
private
def parallel_diff_view?(options, diff_file)
diff --git a/app/serializers/diffs_entity.rb b/app/serializers/diffs_entity.rb
index 02f78180fb0..b709fc7228b 100644
--- a/app/serializers/diffs_entity.rb
+++ b/app/serializers/diffs_entity.rb
@@ -70,13 +70,21 @@ class DiffsEntity < Grape::Entity
expose :diff_files do |diffs, options|
submodule_links = Gitlab::SubmoduleLinks.new(merge_request.project.repository)
- DiffFileEntity.represent(diffs.diff_files, options.merge(submodule_links: submodule_links))
+ 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))
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)
+ end
+
def merge_request
options[:merge_request]
end
diff --git a/app/serializers/paginated_diff_entity.rb b/app/serializers/paginated_diff_entity.rb
index 622da926c69..a31c9d70d4b 100644
--- a/app/serializers/paginated_diff_entity.rb
+++ b/app/serializers/paginated_diff_entity.rb
@@ -10,7 +10,11 @@ class PaginatedDiffEntity < Grape::Entity
expose :diff_files do |diffs, options|
submodule_links = Gitlab::SubmoduleLinks.new(merge_request.project.repository)
- DiffFileEntity.represent(diffs.diff_files, options.merge(submodule_links: submodule_links))
+ 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))
end
expose :pagination do