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
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2024-01-24 09:07:44 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2024-01-24 09:07:44 +0300
commit4dcdd5bebb55bd5522ec180070d4d265e00943b5 (patch)
tree33760c353dd9dc97d0e5a64b107579b89d9110ea /lib
parent3f29b140ab13fd23ed35e759fd2bb6f41ba788ac (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/diff/file.rb12
-rw-r--r--lib/gitlab/diff/file_collection/base.rb5
-rw-r--r--lib/gitlab/diff/file_collection/merge_request_diff_base.rb8
3 files changed, 21 insertions, 4 deletions
diff --git a/lib/gitlab/diff/file.rb b/lib/gitlab/diff/file.rb
index 6ddd8a208bc..7a571887643 100644
--- a/lib/gitlab/diff/file.rb
+++ b/lib/gitlab/diff/file.rb
@@ -5,7 +5,7 @@ module Gitlab
class File
include Gitlab::Utils::StrongMemoize
- attr_reader :diff, :repository, :diff_refs, :fallback_diff_refs, :unique_identifier
+ attr_reader :diff, :repository, :diff_refs, :fallback_diff_refs, :unique_identifier, :max_blob_size
delegate :new_file?, :deleted_file?, :renamed_file?, :unidiff,
:old_path, :new_path, :a_mode, :b_mode, :mode_changed?,
@@ -31,7 +31,8 @@ module Gitlab
diff_refs: nil,
fallback_diff_refs: nil,
stats: nil,
- unique_identifier: nil)
+ unique_identifier: nil,
+ max_blob_size: nil)
@diff = diff
@stats = stats
@@ -39,6 +40,7 @@ module Gitlab
@diff_refs = diff_refs
@fallback_diff_refs = fallback_diff_refs
@unique_identifier = unique_identifier
+ @max_blob_size = max_blob_size
@unfolded = false
# Ensure items are collected in the the batch
@@ -397,7 +399,11 @@ module Gitlab
def fetch_blob(sha, path)
return unless sha
- Blob.lazy(repository, sha, path)
+ if max_blob_size.present?
+ Blob.lazy(repository, sha, path, blob_size_limit: max_blob_size)
+ else
+ Blob.lazy(repository, sha, path)
+ end
end
def total_blob_lines(blob)
diff --git a/lib/gitlab/diff/file_collection/base.rb b/lib/gitlab/diff/file_collection/base.rb
index ae55dae1201..3117b7c8c7f 100644
--- a/lib/gitlab/diff/file_collection/base.rb
+++ b/lib/gitlab/diff/file_collection/base.rb
@@ -119,7 +119,8 @@ module Gitlab
repository: project.repository,
diff_refs: diff_refs,
fallback_diff_refs: fallback_diff_refs,
- stats: stats)
+ stats: stats,
+ max_blob_size: self.class.max_blob_size(project))
if @use_extra_viewer_as_main && diff_file.has_renderable?
diff_file.rendered
@@ -131,6 +132,8 @@ module Gitlab
def sort_diffs(diffs)
Gitlab::Diff::FileCollectionSorter.new(diffs).sort
end
+
+ def self.max_blob_size(_) = nil
end
end
end
diff --git a/lib/gitlab/diff/file_collection/merge_request_diff_base.rb b/lib/gitlab/diff/file_collection/merge_request_diff_base.rb
index 801c1967e0a..9d2fd5e44ee 100644
--- a/lib/gitlab/diff/file_collection/merge_request_diff_base.rb
+++ b/lib/gitlab/diff/file_collection/merge_request_diff_base.rb
@@ -49,6 +49,14 @@ module Gitlab
diff_stats_cache.clear
end
+ override :max_blob_size
+ def self.max_blob_size(project)
+ return unless Feature.enabled?(:increase_diff_file_performance, project)
+
+ [Gitlab::Git::Diff.patch_hard_limit_bytes,
+ Gitlab.config.extra['maximum_text_highlight_size_kilobytes']].max
+ end
+
private
def highlight_cache