Commit af8a060f authored by Nick Thomas's avatar Nick Thomas

Merge branch '219565-increase-limit-for-number-of-files-loaded-for-a-single-diff' into 'master'

Resolve "Increase limit for number of files loaded for a single diff"

See merge request gitlab-org/gitlab!43123
parents 7fffa6e9 8e344aef
...@@ -74,8 +74,8 @@ class Commit ...@@ -74,8 +74,8 @@ class Commit
sha[0..MIN_SHA_LENGTH] sha[0..MIN_SHA_LENGTH]
end end
def diff_safe_lines def diff_safe_lines(project: nil)
Gitlab::Git::DiffCollection.default_limits[:max_lines] Gitlab::Git::DiffCollection.default_limits(project: project)[:max_lines]
end end
def diff_hard_limit_files(project: nil) def diff_hard_limit_files(project: nil)
......
- too_big = diff_file.diff_lines.count > Commit.diff_safe_lines - too_big = diff_file.diff_lines.count > Commit.diff_safe_lines(project: @project)
- if too_big - if too_big
.suppressed-container .suppressed-container
%a.show-suppressed-diff.cursor-pointer.js-show-suppressed-diff= _("Changes suppressed. Click to show.") %a.show-suppressed-diff.cursor-pointer.js-show-suppressed-diff= _("Changes suppressed. Click to show.")
......
...@@ -66,7 +66,9 @@ module Gitlab ...@@ -66,7 +66,9 @@ module Gitlab
end end
def merged_diff_options(diff_options) def merged_diff_options(diff_options)
max_diff_options = ::Commit.max_diff_options(project: @merge_request_diff.project) project = @merge_request_diff.project
max_diff_options = ::Commit.max_diff_options(project: project).merge(project: project)
diff_options.present? ? diff_options.merge(max_diff_options) : max_diff_options diff_options.present? ? diff_options.merge(max_diff_options) : max_diff_options
end end
end end
......
...@@ -11,13 +11,17 @@ module Gitlab ...@@ -11,13 +11,17 @@ module Gitlab
delegate :max_files, :max_lines, :max_bytes, :safe_max_files, :safe_max_lines, :safe_max_bytes, to: :limits delegate :max_files, :max_lines, :max_bytes, :safe_max_files, :safe_max_lines, :safe_max_bytes, to: :limits
def self.default_limits def self.default_limits(project: nil)
{ max_files: 100, max_lines: 5000 } if Feature.enabled?(:increased_diff_limits, project)
{ max_files: 200, max_lines: 7500 }
else
{ max_files: 100, max_lines: 5000 }
end
end end
def self.limits(options = {}) def self.limits(options = {})
limits = {} limits = {}
defaults = default_limits defaults = default_limits(project: options[:project])
limits[:max_files] = options.fetch(:max_files, defaults[:max_files]) limits[:max_files] = options.fetch(:max_files, defaults[:max_files])
limits[:max_lines] = options.fetch(:max_lines, defaults[:max_lines]) limits[:max_lines] = options.fetch(:max_lines, defaults[:max_lines])
limits[:max_bytes] = limits[:max_files] * 5.kilobytes # Average 5 KB per file limits[:max_bytes] = limits[:max_files] * 5.kilobytes # Average 5 KB per file
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment