diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-06-05 16:58:54 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-06-05 16:58:54 +0300 |
commit | 07e7ce31e341cc6e01ea403e2d0f2b8bc1f6bd57 (patch) | |
tree | 2fc0fb2f5e9a781b0f514e8a5193912269e4fcdc /lib/gitlab/git/diff.rb | |
parent | c34107608ecc5c36e80a748eb4c9b88d2b1157cf (diff) | |
parent | 1d3c33b57eeb39df76e78fd37c86532c02aa22ac (diff) |
Merge branch '31983-increase-merge-request-diff-file-size-limit-for-default-toggle-opening' into 'master'
Increase diff limits to 100 KB for collapse and 200 KB overall
Closes #31983
See merge request !11875
Diffstat (limited to 'lib/gitlab/git/diff.rb')
-rw-r--r-- | lib/gitlab/git/diff.rb | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/lib/gitlab/git/diff.rb b/lib/gitlab/git/diff.rb index 7e21994a084..8926aa19925 100644 --- a/lib/gitlab/git/diff.rb +++ b/lib/gitlab/git/diff.rb @@ -20,13 +20,25 @@ module Gitlab # We need this accessor because of `to_hash` and `init_from_hash` attr_accessor :too_large - # The maximum size of a diff to display. - SIZE_LIMIT = 100.kilobytes + class << self + # The maximum size of a diff to display. + def size_limit + if Feature.enabled?('gitlab_git_diff_size_limit_increase') + 200.kilobytes + else + 100.kilobytes + end + end - # The maximum size before a diff is collapsed. - COLLAPSE_LIMIT = 10.kilobytes + # The maximum size before a diff is collapsed. + def collapse_limit + if Feature.enabled?('gitlab_git_diff_size_limit_increase') + 100.kilobytes + else + 10.kilobytes + end + end - class << self def between(repo, head, base, options = {}, *paths) straight = options.delete(:straight) || false @@ -231,7 +243,7 @@ module Gitlab def too_large? if @too_large.nil? - @too_large = @diff.bytesize >= SIZE_LIMIT + @too_large = @diff.bytesize >= self.class.size_limit else @too_large end @@ -246,7 +258,7 @@ module Gitlab def collapsed? return @collapsed if defined?(@collapsed) - @collapsed = !expanded && @diff.bytesize >= COLLAPSE_LIMIT + @collapsed = !expanded && @diff.bytesize >= self.class.collapse_limit end def collapse! @@ -318,14 +330,14 @@ module Gitlab hunk.each_line do |line| size += line.content.bytesize - if size >= SIZE_LIMIT + if size >= self.class.size_limit too_large! return true end end end - if !expanded && size >= COLLAPSE_LIMIT + if !expanded && size >= self.class.collapse_limit collapse! return true end |