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>2021-06-16 21:25:58 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-06-16 21:25:58 +0300
commita5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch)
treefb69158581673816a8cd895f9d352dcb3c678b1e /lib/gitlab/diff
parentd16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff)
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'lib/gitlab/diff')
-rw-r--r--lib/gitlab/diff/file_collection/base.rb15
-rw-r--r--lib/gitlab/diff/file_collection/merge_request_diff_batch.rb24
-rw-r--r--lib/gitlab/diff/highlight.rb6
-rw-r--r--lib/gitlab/diff/highlight_cache.rb1
4 files changed, 31 insertions, 15 deletions
diff --git a/lib/gitlab/diff/file_collection/base.rb b/lib/gitlab/diff/file_collection/base.rb
index 9ed03c05f0b..f3f0f227a8c 100644
--- a/lib/gitlab/diff/file_collection/base.rb
+++ b/lib/gitlab/diff/file_collection/base.rb
@@ -19,6 +19,7 @@ module Gitlab
@diffable = diffable
@include_stats = diff_options.delete(:include_stats)
+ @pagination_data = diff_options.delete(:pagination_data)
@project = project
@diff_options = diff_options
@diff_refs = diff_refs
@@ -47,11 +48,7 @@ module Gitlab
end
def pagination_data
- {
- current_page: nil,
- next_page: nil,
- total_pages: nil
- }
+ @pagination_data || empty_pagination_data
end
# This mutates `diff_files` lines.
@@ -90,6 +87,14 @@ module Gitlab
private
+ def empty_pagination_data
+ {
+ current_page: nil,
+ next_page: nil,
+ total_pages: nil
+ }
+ end
+
def diff_stats_collection
strong_memoize(:diff_stats) do
next unless fetch_diff_stats?
diff --git a/lib/gitlab/diff/file_collection/merge_request_diff_batch.rb b/lib/gitlab/diff/file_collection/merge_request_diff_batch.rb
index 64523f3b730..5ff7c88970c 100644
--- a/lib/gitlab/diff/file_collection/merge_request_diff_batch.rb
+++ b/lib/gitlab/diff/file_collection/merge_request_diff_batch.rb
@@ -21,9 +21,9 @@ module Gitlab
@paginated_collection = load_paginated_collection(batch_page, batch_size, diff_options)
@pagination_data = {
- current_page: batch_gradual_load? ? nil : @paginated_collection.current_page,
- next_page: batch_gradual_load? ? nil : @paginated_collection.next_page,
- total_pages: batch_gradual_load? ? relation.size : @paginated_collection.total_pages
+ current_page: current_page,
+ next_page: next_page,
+ total_pages: total_pages
}
end
@@ -62,6 +62,24 @@ module Gitlab
@merge_request_diff.merge_request_diff_files
end
+ def current_page
+ return if @paginated_collection.blank?
+
+ batch_gradual_load? ? nil : @paginated_collection.current_page
+ end
+
+ def next_page
+ return if @paginated_collection.blank?
+
+ batch_gradual_load? ? nil : @paginated_collection.next_page
+ end
+
+ def total_pages
+ return if @paginated_collection.blank?
+
+ batch_gradual_load? ? relation.size : @paginated_collection.total_pages
+ end
+
# rubocop: disable CodeReuse/ActiveRecord
def load_paginated_collection(batch_page, batch_size, diff_options)
batch_page ||= DEFAULT_BATCH_PAGE
diff --git a/lib/gitlab/diff/highlight.rb b/lib/gitlab/diff/highlight.rb
index 6a41ed0f29e..32ce35110f8 100644
--- a/lib/gitlab/diff/highlight.rb
+++ b/lib/gitlab/diff/highlight.rb
@@ -70,12 +70,6 @@ module Gitlab
return rich_line if marker_ranges.blank?
begin
- # MarkerRange objects are converted to Ranges to keep the previous behavior
- # Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/324068
- if Feature.disabled?(:introduce_marker_ranges, project, default_enabled: :yaml)
- marker_ranges = marker_ranges.map { |marker_range| marker_range.to_range }
- end
-
InlineDiffMarker.new(diff_line.text, rich_line).mark(marker_ranges)
# This should only happen when the encoding of the diff doesn't
# match the blob, which is a bug. But we shouldn't fail to render
diff --git a/lib/gitlab/diff/highlight_cache.rb b/lib/gitlab/diff/highlight_cache.rb
index 209462fd6e9..a792eafde79 100644
--- a/lib/gitlab/diff/highlight_cache.rb
+++ b/lib/gitlab/diff/highlight_cache.rb
@@ -74,7 +74,6 @@ module Gitlab
diffable.cache_key,
VERSION,
diff_options,
- Feature.enabled?(:introduce_marker_ranges, diffable.project, default_enabled: :yaml),
Feature.enabled?(:use_marker_ranges, diffable.project, default_enabled: :yaml),
Feature.enabled?(:diff_line_syntax_highlighting, diffable.project, default_enabled: :yaml)
].join(":")