diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-08 00:07:43 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-08 00:07:43 +0000 |
commit | 2b3bfe8fc59ed4cdc385955cdb38cbd481b45426 (patch) | |
tree | 6b570a8d134fb2beeacf11bbcc79ff22123156ec /app | |
parent | d203316c80aa27cf747aa29df9f7c2d374965b5f (diff) | |
download | gitlab-ce-2b3bfe8fc59ed4cdc385955cdb38cbd481b45426.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/projects_controller.rb | 1 | ||||
-rw-r--r-- | app/graphql/mutations/award_emojis/toggle.rb | 7 | ||||
-rw-r--r-- | app/graphql/types/issue_type.rb | 2 | ||||
-rw-r--r-- | app/graphql/types/permission_types/base_permission_type.rb | 2 | ||||
-rw-r--r-- | app/graphql/types/project_type.rb | 4 | ||||
-rw-r--r-- | app/models/diff_viewer/base.rb | 2 | ||||
-rw-r--r-- | app/models/key.rb | 8 | ||||
-rw-r--r-- | app/models/project.rb | 7 | ||||
-rw-r--r-- | app/validators/key_restriction_validator.rb | 3 | ||||
-rw-r--r-- | app/views/projects/blob/_render_error.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/blob/viewers/_contributing.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/default_branch/_show.html.haml | 24 | ||||
-rw-r--r-- | app/views/shared/form_elements/_description.html.haml | 4 | ||||
-rw-r--r-- | app/views/shared/issuable/_form.html.haml | 1 | ||||
-rw-r--r-- | app/views/shared/issuable/form/_template_selector.html.haml | 2 | ||||
-rw-r--r-- | app/workers/chat_notification_worker.rb | 16 |
16 files changed, 59 insertions, 28 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 5a65b0eb36b..dd392bd39a8 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -386,6 +386,7 @@ class ProjectsController < Projects::ApplicationController :template_project_id, :merge_method, :initialize_with_readme, + :autoclose_referenced_issues, project_feature_attributes: %i[ builds_access_level diff --git a/app/graphql/mutations/award_emojis/toggle.rb b/app/graphql/mutations/award_emojis/toggle.rb index d822048f3a6..22eab4812a1 100644 --- a/app/graphql/mutations/award_emojis/toggle.rb +++ b/app/graphql/mutations/award_emojis/toggle.rb @@ -5,10 +5,9 @@ module Mutations class Toggle < Base graphql_name 'ToggleAwardEmoji' - field :toggledOn, - GraphQL::BOOLEAN_TYPE, - null: false, - description: 'True when the emoji was awarded, false when it was removed' + field :toggledOn, GraphQL::BOOLEAN_TYPE, null: false, + description: 'Indicates the status of the emoji. ' \ + 'True if the toggle awarded the emoji, and false if the toggle removed the emoji.' def resolve(args) awardable = authorized_find!(id: args[:awardable_id]) diff --git a/app/graphql/types/issue_type.rb b/app/graphql/types/issue_type.rb index 4cbb849da3a..11850e5865f 100644 --- a/app/graphql/types/issue_type.rb +++ b/app/graphql/types/issue_type.rb @@ -69,7 +69,7 @@ module Types field :participants, Types::UserType.connection_type, null: true, complexity: 5, description: 'List of participants in the issue' field :subscribed, GraphQL::BOOLEAN_TYPE, method: :subscribed?, null: false, complexity: 5, - description: 'Boolean flag for whether the currently logged in user is subscribed to this issue' + description: 'Indicates the currently logged in user is subscribed to the issue' field :time_estimate, GraphQL::INT_TYPE, null: false, description: 'Time estimate of the issue' field :total_time_spent, GraphQL::INT_TYPE, null: false, diff --git a/app/graphql/types/permission_types/base_permission_type.rb b/app/graphql/types/permission_types/base_permission_type.rb index 73049ebed7b..deb8560bd79 100644 --- a/app/graphql/types/permission_types/base_permission_type.rb +++ b/app/graphql/types/permission_types/base_permission_type.rb @@ -25,7 +25,7 @@ module Types kword_args = kword_args.reverse_merge( name: name, type: GraphQL::BOOLEAN_TYPE, - description: "Whether or not a user can perform `#{name}` on this resource", + description: "Indicates the user can perform `#{name}` on this resource", null: false) field(**kword_args) # rubocop:disable Graphql/Descriptions diff --git a/app/graphql/types/project_type.rb b/app/graphql/types/project_type.rb index cd894f9775a..0bd2b0c81d9 100644 --- a/app/graphql/types/project_type.rb +++ b/app/graphql/types/project_type.rb @@ -46,7 +46,7 @@ module Types description: 'Timestamp of the project last activity' field :archived, GraphQL::BOOLEAN_TYPE, null: true, - description: 'Archived status of the project' + description: 'Indicates the archived status of the project' field :visibility, GraphQL::STRING_TYPE, null: true, description: 'Visibility of the project' @@ -102,6 +102,8 @@ module Types description: 'Indicates if a link to create or view a merge request should display after a push to Git repositories of the project from the command line' field :remove_source_branch_after_merge, GraphQL::BOOLEAN_TYPE, null: true, description: 'Indicates if `Delete source branch` option should be enabled by default for all new merge requests of the project' + field :autoclose_referenced_issues, GraphQL::BOOLEAN_TYPE, null: true, + description: 'Indicates if issues referenced by merge requests and commits within the default branch are closed automatically' field :namespace, Types::NamespaceType, null: true, description: 'Namespace of the project' diff --git a/app/models/diff_viewer/base.rb b/app/models/diff_viewer/base.rb index 22c8fe73563..37831683555 100644 --- a/app/models/diff_viewer/base.rb +++ b/app/models/diff_viewer/base.rb @@ -89,7 +89,7 @@ module DiffViewer { viewer: switcher_title, reason: render_error_reason, - options: render_error_options.to_sentence(two_words_connector: _(' or '), last_word_connector: _(', or ')) + options: Gitlab::Utils.to_exclusive_sentence(render_error_options) } end diff --git a/app/models/key.rb b/app/models/key.rb index e549c59b58f..71188f210bb 100644 --- a/app/models/key.rb +++ b/app/models/key.rb @@ -142,13 +142,9 @@ class Key < ApplicationRecord end def forbidden_key_type_message - allowed_types = - Gitlab::CurrentSettings - .allowed_key_types - .map(&:upcase) - .to_sentence(last_word_connector: ', or ', two_words_connector: ' or ') + allowed_types = Gitlab::CurrentSettings.allowed_key_types.map(&:upcase) - "type is forbidden. Must be #{allowed_types}" + "type is forbidden. Must be #{Gitlab::Utils.to_exclusive_sentence(allowed_types)}" end end diff --git a/app/models/project.rb b/app/models/project.rb index 057bcbabbeb..25819bc2b85 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -75,6 +75,7 @@ class Project < ApplicationRecord default_value_for :snippets_enabled, gitlab_config_features.snippets default_value_for :only_allow_merge_if_all_discussions_are_resolved, false default_value_for :remove_source_branch_after_merge, true + default_value_for :autoclose_referenced_issues, true default_value_for(:ci_config_path) { Gitlab::CurrentSettings.default_ci_config_path } add_authentication_token_field :runners_token, encrypted: -> { Feature.enabled?(:projects_tokens_optional_encryption, default_enabled: true) ? :optional : :required } @@ -679,6 +680,12 @@ class Project < ApplicationRecord end end + def autoclose_referenced_issues + return true if super.nil? + + super + end + def preload_protected_branches preloader = ActiveRecord::Associations::Preloader.new preloader.preload(self, protected_branches: [:push_access_levels, :merge_access_levels]) diff --git a/app/validators/key_restriction_validator.rb b/app/validators/key_restriction_validator.rb index 891d13b1596..9809047ae83 100644 --- a/app/validators/key_restriction_validator.rb +++ b/app/validators/key_restriction_validator.rb @@ -21,7 +21,8 @@ class KeyRestrictionValidator < ActiveModel::EachValidator def supported_sizes_message sizes = self.class.supported_sizes(options[:type]) - sizes.to_sentence(last_word_connector: ', or ', two_words_connector: ' or ') + + Gitlab::Utils.to_exclusive_sentence(sizes) end def valid_restriction?(value) diff --git a/app/views/projects/blob/_render_error.html.haml b/app/views/projects/blob/_render_error.html.haml index 9eef6cafd04..1ff68cd2d11 100644 --- a/app/views/projects/blob/_render_error.html.haml +++ b/app/views/projects/blob/_render_error.html.haml @@ -3,5 +3,5 @@ The #{viewer.switcher_title} could not be displayed because #{blob_render_error_reason(viewer)}. You can - = blob_render_error_options(viewer).to_sentence(two_words_connector: ' or ', last_word_connector: ', or ').html_safe + = Gitlab::Utils.to_exclusive_sentence(blob_render_error_options(viewer)).html_safe instead. diff --git a/app/views/projects/blob/viewers/_contributing.html.haml b/app/views/projects/blob/viewers/_contributing.html.haml index c78f04c9c7c..546c064c06f 100644 --- a/app/views/projects/blob/viewers/_contributing.html.haml +++ b/app/views/projects/blob/viewers/_contributing.html.haml @@ -4,6 +4,6 @@ After you've reviewed these contribution guidelines, you'll be all set to - options = contribution_options(viewer.project) - if options.any? = succeed '.' do - = options.to_sentence(two_words_connector: ' or ', last_word_connector: ', or ').html_safe + = Gitlab::Utils.to_exclusive_sentence(options).html_safe - else contribute to this project. diff --git a/app/views/projects/default_branch/_show.html.haml b/app/views/projects/default_branch/_show.html.haml index 59efcde5825..6a09004143e 100644 --- a/app/views/projects/default_branch/_show.html.haml +++ b/app/views/projects/default_branch/_show.html.haml @@ -9,13 +9,23 @@ = _('Select the branch you want to set as the default for this project. All merge requests and commits will automatically be made against this branch unless you specify a different one.') .settings-content - - if @project.empty_repo? - .text-secondary - = _('A default branch cannot be chosen for an empty project.') - - else - = form_for [@project.namespace.becomes(Namespace), @project], remote: true, html: { multipart: true, anchor: 'default-branch-settings' }, authenticity_token: true do |f| - %fieldset + = form_for [@project.namespace.becomes(Namespace), @project], remote: true, html: { multipart: true, anchor: 'default-branch-settings' }, authenticity_token: true do |f| + %fieldset + - if @project.empty_repo? + .text-secondary + = _('A default branch cannot be chosen for an empty project.') + - else .form-group = f.label :default_branch, "Default Branch", class: 'label-bold' = f.select(:default_branch, @project.repository.branch_names, {}, {class: 'select2 select-wide'}) - = f.submit 'Save changes', class: "btn btn-success" + + .form-group + .form-check + = f.check_box :autoclose_referenced_issues, class: 'form-check-input' + = f.label :autoclose_referenced_issues, class: 'form-check-label' do + %strong= _("Auto-close referenced issues on default branch") + .form-text.text-muted + = _("Issues referenced by merge requests and commits within the default branch will be closed automatically") + = link_to icon('question-circle'), help_page_path('user/project/issues/managing_issues.html', anchor: 'disabling-automatic-issue-closing'), target: '_blank' + + = f.submit 'Save changes', class: "btn btn-success" diff --git a/app/views/shared/form_elements/_description.html.haml b/app/views/shared/form_elements/_description.html.haml index 9db6184ebca..2f2e6d83f9f 100644 --- a/app/views/shared/form_elements/_description.html.haml +++ b/app/views/shared/form_elements/_description.html.haml @@ -1,6 +1,8 @@ - project = local_assigns.fetch(:project) - model = local_assigns.fetch(:model) + + - form = local_assigns.fetch(:form) - placeholder = model.is_a?(MergeRequest) ? _('Describe the goal of the changes and what reviewers should be aware of.') : _('Write a comment or drag your files hereā¦') - supports_quick_actions = model.new_record? @@ -14,6 +16,8 @@ = form.label :description, 'Description', class: 'col-form-label col-sm-2' .col-sm-10 + - if model.is_a?(Issuable) + = render 'shared/issuable/form/template_selector', issuable: model = render layout: 'projects/md_preview', locals: { url: preview_url, referenced_users: true } do = render 'projects/zen', f: form, attr: :description, classes: 'note-textarea qa-issuable-form-description rspec-issuable-form-description', diff --git a/app/views/shared/issuable/_form.html.haml b/app/views/shared/issuable/_form.html.haml index 0fb23adc31f..a020a04e366 100644 --- a/app/views/shared/issuable/_form.html.haml +++ b/app/views/shared/issuable/_form.html.haml @@ -17,7 +17,6 @@ .form-group.row = form.label :title, class: 'col-form-label col-sm-2' - = render 'shared/issuable/form/template_selector', issuable: issuable = render 'shared/issuable/form/title', issuable: issuable, form: form, has_wip_commits: commits && commits.detect(&:work_in_progress?) #js-suggestions{ data: { project_path: @project.full_path } } diff --git a/app/views/shared/issuable/form/_template_selector.html.haml b/app/views/shared/issuable/form/_template_selector.html.haml index d613bd31d81..bf34ea4a1b2 100644 --- a/app/views/shared/issuable/form/_template_selector.html.haml +++ b/app/views/shared/issuable/form/_template_selector.html.haml @@ -2,7 +2,7 @@ - return unless issuable && issuable_templates(issuable).any? -.col-sm-3.col-lg-2 +.issuable-form-select-holder.selectbox.form-group .js-issuable-selector-wrap{ data: { issuable_type: issuable.to_ability_name } } = template_dropdown_tag(issuable) do %ul.dropdown-footer-list diff --git a/app/workers/chat_notification_worker.rb b/app/workers/chat_notification_worker.rb index 42a23cd472a..6162dcf9d38 100644 --- a/app/workers/chat_notification_worker.rb +++ b/app/workers/chat_notification_worker.rb @@ -3,6 +3,9 @@ class ChatNotificationWorker include ApplicationWorker + TimeoutExceeded = Class.new(StandardError) + + sidekiq_options retry: false feature_category :chatops latency_sensitive_worker! # TODO: break this into multiple jobs @@ -11,18 +14,21 @@ class ChatNotificationWorker # worker_has_external_dependencies! RESCHEDULE_INTERVAL = 2.seconds + RESCHEDULE_TIMEOUT = 5.minutes # rubocop: disable CodeReuse/ActiveRecord - def perform(build_id) + def perform(build_id, reschedule_count = 0) Ci::Build.find_by(id: build_id).try do |build| send_response(build) end rescue Gitlab::Chat::Output::MissingBuildSectionError + raise TimeoutExceeded if timeout_exceeded?(reschedule_count) + # The creation of traces and sections appears to be eventually consistent. # As a result it's possible for us to run the above code before the trace # sections are present. To better handle such cases we'll just reschedule # the job instead of producing an error. - self.class.perform_in(RESCHEDULE_INTERVAL, build_id) + self.class.perform_in(RESCHEDULE_INTERVAL, build_id, reschedule_count + 1) end # rubocop: enable CodeReuse/ActiveRecord @@ -37,4 +43,10 @@ class ChatNotificationWorker end end end + + private + + def timeout_exceeded?(reschedule_count) + (reschedule_count * RESCHEDULE_INTERVAL) >= RESCHEDULE_TIMEOUT + end end |