diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-10-02 14:39:55 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-10-02 14:39:55 +0000 |
commit | 4716e81f9dc73b95e45df26fd339b75aaf6b48f6 (patch) | |
tree | 07df6c288252638e697399a1c7c5bc400441effc /lib | |
parent | ca88df3219a2e1f4754156b761efa9f62c1c3a42 (diff) | |
parent | a5d47bb063624bb30064c8e44c05de05bb63b25a (diff) | |
download | gitlab-ce-4716e81f9dc73b95e45df26fd339b75aaf6b48f6.tar.gz |
Merge branch 'revert-configurable-size-limits' into 'master'
Revert "Increase diff limits to 100 KB for collapse and 200 KB overall"
See merge request gitlab-org/gitlab-ce!14628
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/git/diff.rb | 46 |
1 files changed, 9 insertions, 37 deletions
diff --git a/lib/gitlab/git/diff.rb b/lib/gitlab/git/diff.rb index 096301d300f..ca94b4baa59 100644 --- a/lib/gitlab/git/diff.rb +++ b/lib/gitlab/git/diff.rb @@ -24,41 +24,13 @@ module Gitlab SERIALIZE_KEYS = %i(diff new_path old_path a_mode b_mode new_file renamed_file deleted_file too_large).freeze - class << self - # The maximum size of a diff to display. - def size_limit - if RequestStore.active? - RequestStore['gitlab_git_diff_size_limit'] ||= find_size_limit - else - find_size_limit - end - end - - # The maximum size before a diff is collapsed. - def collapse_limit - if RequestStore.active? - RequestStore['gitlab_git_diff_collapse_limit'] ||= find_collapse_limit - else - find_collapse_limit - end - end + # The maximum size of a diff to display. + SIZE_LIMIT = 100.kilobytes - def find_size_limit - if Feature.enabled?('gitlab_git_diff_size_limit_increase') - 200.kilobytes - else - 100.kilobytes - end - end - - def find_collapse_limit - if Feature.enabled?('gitlab_git_diff_size_limit_increase') - 100.kilobytes - else - 10.kilobytes - end - end + # The maximum size before a diff is collapsed. + COLLAPSE_LIMIT = 10.kilobytes + class << self def between(repo, head, base, options = {}, *paths) straight = options.delete(:straight) || false @@ -172,7 +144,7 @@ module Gitlab def too_large? if @too_large.nil? - @too_large = @diff.bytesize >= self.class.size_limit + @too_large = @diff.bytesize >= SIZE_LIMIT else @too_large end @@ -190,7 +162,7 @@ module Gitlab def collapsed? return @collapsed if defined?(@collapsed) - @collapsed = !expanded && @diff.bytesize >= self.class.collapse_limit + @collapsed = !expanded && @diff.bytesize >= COLLAPSE_LIMIT end def collapse! @@ -275,14 +247,14 @@ module Gitlab hunk.each_line do |line| size += line.content.bytesize - if size >= self.class.size_limit + if size >= SIZE_LIMIT too_large! return true end end end - if !expanded && size >= self.class.collapse_limit + if !expanded && size >= COLLAPSE_LIMIT collapse! return true end |