diff options
author | Oswaldo Ferreira <oswaldo@gitlab.com> | 2018-09-24 18:30:49 +0300 |
---|---|---|
committer | Oswaldo Ferreira <oswaldo@gitlab.com> | 2018-10-01 17:58:21 +0300 |
commit | 4fbca2a346dc4c2c2c57e6a5bc3d13a8c3eeb23e (patch) | |
tree | 85ac3e8ffe36470fa4fa424c58e372d585417f03 /app | |
parent | 4d4522c15860529693305dc0fc0231c22eaf8a31 (diff) |
Make single diff patch limit configurable
- Creates a new column to hold the single patch limit value on
application_settings
- Allows updating this value through the application_settings API
- Calculates single diff patch collapsing limit based on
diff_max_patch_bytes column
- Updates diff limit documentation
- Adds documentation (with warning) as of how one can update this limit
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/application_settings_helper.rb | 3 | ||||
-rw-r--r-- | app/models/application_setting.rb | 9 | ||||
-rw-r--r-- | app/views/admin/application_settings/_diff_limits.html.haml | 16 | ||||
-rw-r--r-- | app/views/admin/application_settings/show.html.haml | 11 |
4 files changed, 37 insertions, 2 deletions
diff --git a/app/helpers/application_settings_helper.rb b/app/helpers/application_settings_helper.rb index c9a5431d18e..15cbfeea609 100644 --- a/app/helpers/application_settings_helper.rb +++ b/app/helpers/application_settings_helper.rb @@ -254,7 +254,8 @@ module ApplicationSettingsHelper :user_default_internal_regex, :user_oauth_applications, :version_check_enabled, - :web_ide_clientside_preview_enabled + :web_ide_clientside_preview_enabled, + :diff_max_patch_bytes ] end diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index 5f835a8da75..65a2f760f93 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -182,6 +182,12 @@ class ApplicationSetting < ActiveRecord::Base numericality: { less_than_or_equal_to: :gitaly_timeout_default }, if: :gitaly_timeout_default + validates :diff_max_patch_bytes, + presence: true, + numericality: { only_integer: true, + greater_than_or_equal_to: Gitlab::Git::Diff::DEFAULT_MAX_PATCH_BYTES, + less_than_or_equal_to: Gitlab::Git::Diff::MAX_PATCH_BYTES_UPPER_BOUND } + validates :user_default_internal_regex, js_regex: true, allow_nil: true SUPPORTED_KEY_TYPES.each do |type| @@ -293,7 +299,8 @@ class ApplicationSetting < ActiveRecord::Base user_default_external: false, user_default_internal_regex: nil, user_show_add_ssh_key_message: true, - usage_stats_set_by_user_id: nil + usage_stats_set_by_user_id: nil, + diff_max_patch_bytes: Gitlab::Git::Diff::DEFAULT_MAX_PATCH_BYTES } end diff --git a/app/views/admin/application_settings/_diff_limits.html.haml b/app/views/admin/application_settings/_diff_limits.html.haml new file mode 100644 index 00000000000..408e569fe07 --- /dev/null +++ b/app/views/admin/application_settings/_diff_limits.html.haml @@ -0,0 +1,16 @@ += form_for @application_setting, url: admin_application_settings_path(anchor: 'js-merge-request-settings'), html: { class: 'fieldset-form' } do |f| + = form_errors(@application_setting) + + %fieldset + .form-group + = f.label :diff_max_patch_bytes, 'Maximum diff patch size (Bytes)', class: 'label-light' + = f.number_field :diff_max_patch_bytes, class: 'form-control' + %span.form-text.text-muted + Diff files surpassing this limit will be presented as 'too large' + and won't be expandable. + + = link_to icon('question-circle'), + help_page_path('user/admin_area/diff_limits', + anchor: 'maximum-diff-patch-size') + + = f.submit _('Save changes'), class: 'btn btn-success' diff --git a/app/views/admin/application_settings/show.html.haml b/app/views/admin/application_settings/show.html.haml index e2043183a97..761555c4189 100644 --- a/app/views/admin/application_settings/show.html.haml +++ b/app/views/admin/application_settings/show.html.haml @@ -24,6 +24,17 @@ .settings-content = render 'account_and_limit' +%section.settings.as-diff-limits.no-animate#js-merge-request-settings{ class: ('expanded' if expanded_by_default?) } + .settings-header + %h4 + = _('Diff limits') + %button.btn.js-settings-toggle{ type: 'button' } + = expanded_by_default? ? _('Collapse') : _('Expand') + %p + = _('Diff content limits') + .settings-content + = render 'diff_limits' + %section.settings.as-signup.no-animate#js-signup-settings{ class: ('expanded' if expanded_by_default?) } .settings-header %h4 |