diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-16 15:07:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-16 15:07:11 +0300 |
commit | d87800c3cfa21bde64704542d61a587c5ff4306e (patch) | |
tree | 4921659e458ef0b21a637ba68a2765c93e4f20b7 /app | |
parent | 8ae36d93f1a63874b584f0488fde88c1fee999c4 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
34 files changed, 148 insertions, 159 deletions
diff --git a/app/assets/javascripts/diffs/components/diff_file_header.vue b/app/assets/javascripts/diffs/components/diff_file_header.vue index 07b60330f43..36252c2cf87 100644 --- a/app/assets/javascripts/diffs/components/diff_file_header.vue +++ b/app/assets/javascripts/diffs/components/diff_file_header.vue @@ -462,7 +462,12 @@ export default { v-if="showGenerateTestFileButton" @click="setGenerateTestFilePath(diffFile.new_path)" > - {{ __('Suggest test cases') }} + <span + class="gl-display-flex gl-justify-content-space-between gl-align-items-center gl-mr-n3!" + > + {{ __('Suggest test cases') }} + <gl-icon name="tanuki-ai" class="gl-text-purple-600" /> + </span> </gl-dropdown-item> <gl-dropdown-item v-if="diffFile.replaced_view_path" diff --git a/app/assets/javascripts/editor/schema/ci.json b/app/assets/javascripts/editor/schema/ci.json index 8e307bc1f19..3a1188d7aab 100644 --- a/app/assets/javascripts/editor/schema/ci.json +++ b/app/assets/javascripts/editor/schema/ci.json @@ -830,7 +830,8 @@ { "type": "string", "enum": [ - "never" + "never", + "always" ] }, { diff --git a/app/assets/javascripts/lib/utils/common_utils.js b/app/assets/javascripts/lib/utils/common_utils.js index 0fb034e8b3e..7795dac18bc 100644 --- a/app/assets/javascripts/lib/utils/common_utils.js +++ b/app/assets/javascripts/lib/utils/common_utils.js @@ -82,6 +82,7 @@ export const handleLocationHash = () => { const fixedTabs = document.querySelector('.js-tabs-affix'); const fixedDiffStats = document.querySelector('.js-diff-files-changed'); const fixedNav = document.querySelector('.navbar-gitlab'); + const fixedTopBar = document.querySelector('.top-bar-fixed'); const performanceBar = document.querySelector('#js-peek'); const topPadding = 8; const diffFileHeader = document.querySelector('.js-file-title'); @@ -93,6 +94,7 @@ export const handleLocationHash = () => { adjustment -= getElementOffsetHeight(fixedNav); adjustment -= getElementOffsetHeight(fixedTabs); adjustment -= getElementOffsetHeight(fixedDiffStats); + adjustment -= getElementOffsetHeight(fixedTopBar); adjustment -= getElementOffsetHeight(performanceBar); adjustment -= getElementOffsetHeight(diffFileHeader); adjustment -= getElementOffsetHeight(versionMenusContainer); @@ -153,6 +155,7 @@ export const contentTop = () => { const heightCalculators = [ () => getOuterHeight('#js-peek'), () => getOuterHeight('.navbar-gitlab'), + () => getOuterHeight('.top-bar-fixed'), ({ desktop }) => { const mrStickyHeader = document.querySelector('.merge-request-sticky-header'); if (mrStickyHeader) { diff --git a/app/assets/javascripts/merge_request.js b/app/assets/javascripts/merge_request.js index 1e02703cbe7..c837583dd45 100644 --- a/app/assets/javascripts/merge_request.js +++ b/app/assets/javascripts/merge_request.js @@ -5,7 +5,6 @@ import { createAlert } from '~/alert'; import { TYPE_MERGE_REQUEST } from '~/issues/constants'; import toast from '~/vue_shared/plugins/global_toast'; import { __ } from '~/locale'; -import eventHub from '~/vue_merge_request_widget/event_hub'; import { loadingIconForLegacyJS } from '~/loading_icon_for_legacy_js'; import axios from './lib/utils/axios_utils'; import { addDelimiter } from './lib/utils/text_utility'; @@ -146,10 +145,6 @@ MergeRequest.decreaseCounter = function (by = 1) { }; MergeRequest.toggleDraftStatus = function (title, isReady) { - if (!window.gon?.features?.realtimeMrStatusChange) { - eventHub.$emit('MRWidgetUpdateRequested'); - } - if (isReady) { toast(__('Marked as ready. Merging is now allowed.')); } else { diff --git a/app/assets/javascripts/merge_requests/components/sticky_header.vue b/app/assets/javascripts/merge_requests/components/sticky_header.vue index a66490b5f75..c6e8a9ea582 100644 --- a/app/assets/javascripts/merge_requests/components/sticky_header.vue +++ b/app/assets/javascripts/merge_requests/components/sticky_header.vue @@ -25,7 +25,7 @@ export default { }; }, skip() { - return !this.issuableId || !this.glFeatures.realtimeMrStatusChange; + return !this.issuableId; }, result({ data: { mergeRequestMergeStatusUpdated } }) { if (mergeRequestMergeStatusUpdated) { diff --git a/app/assets/javascripts/persistent_user_callouts.js b/app/assets/javascripts/persistent_user_callouts.js index 9940575edc3..2c93b3b636a 100644 --- a/app/assets/javascripts/persistent_user_callouts.js +++ b/app/assets/javascripts/persistent_user_callouts.js @@ -26,6 +26,7 @@ const PERSISTENT_USER_CALLOUTS = [ '.js-branch-rules-info-callout', '.js-new-navigation-callout', '.js-code-suggestions-third-party-callout', + '.js-namespace-over-storage-users-combined-alert', ]; const initCallouts = () => { diff --git a/app/assets/javascripts/pipelines/components/pipelines_list/failure_widget/widget_failed_job_row.vue b/app/assets/javascripts/pipelines/components/pipelines_list/failure_widget/widget_failed_job_row.vue index d48e6dc289b..e40e30f2b8d 100644 --- a/app/assets/javascripts/pipelines/components/pipelines_list/failure_widget/widget_failed_job_row.vue +++ b/app/assets/javascripts/pipelines/components/pipelines_list/failure_widget/widget_failed_job_row.vue @@ -1,15 +1,107 @@ <script> +import { GlCollapse, GlIcon, GlLink } from '@gitlab/ui'; +import { s__, sprintf } from '~/locale'; +import { getIdFromGraphQLId } from '~/graphql_shared/utils'; +import CiIcon from '~/vue_shared/components/ci_icon.vue'; +import SafeHtml from '~/vue_shared/directives/safe_html'; + export default { + components: { + CiIcon, + GlCollapse, + GlIcon, + GlLink, + }, + directives: { + SafeHtml, + }, props: { job: { type: Object, required: true, }, }, + data() { + return { + isJobLogVisible: false, + isHovered: false, + }; + }, + computed: { + activeClass() { + return this.isHovered ? 'gl-bg-gray-50' : ''; + }, + isVisibleId() { + return `log-${this.isJobLogVisible ? 'is-visible' : 'is-hidden'}`; + }, + jobChevronName() { + return this.isJobLogVisible ? 'chevron-down' : 'chevron-right'; + }, + jobTrace() { + return this.job?.trace?.htmlSummary || this.$options.i18n.noTraceText; + }, + parsedJobId() { + return getIdFromGraphQLId(this.job.id); + }, + tooltipText() { + return sprintf(this.$options.i18n.jobActionTooltipText, { jobName: this.job.name }); + }, + }, + methods: { + setActiveRow() { + this.isHovered = true; + }, + resetActiveRow() { + this.isHovered = false; + }, + toggleJobLog(e) { + // Do not toggle the log visibility when clicking on a link + if (e.target.tagName === 'A') { + return; + } + + this.isJobLogVisible = !this.isJobLogVisible; + }, + }, + i18n: { + jobActionTooltipText: s__('Pipelines|Retry %{jobName} Job'), + noTraceText: s__('Job|No job log'), + }, }; </script> <template> <div class="container-fluid gl-grid-tpl-rows-auto"> - {{ job.name }} + <div + class="row gl-py-4 gl-cursor-pointer gl-display-flex gl-align-items-center" + :class="activeClass" + :aria-pressed="isJobLogVisible" + role="button" + tabindex="0" + data-testid="widget-row" + @click="toggleJobLog" + @keyup.enter="toggleJobLog" + @keyup.space="toggleJobLog" + @mouseover="setActiveRow" + @mouseout="resetActiveRow" + > + <div class="col-6 gl-text-gray-900 gl-font-weight-bold gl-text-left"> + <gl-icon :name="jobChevronName" class="gl-fill-blue-500" /> + <ci-icon :status="job.detailedStatus" /> + {{ job.name }} + </div> + <div class="col-2 gl-text-left">{{ job.stage.name }}</div> + <div class="col-2 gl-text-left"> + <gl-link :href="job.webPath">#{{ parsedJobId }}</gl-link> + </div> + </div> + <div class="row"> + <gl-collapse :visible="isJobLogVisible" class="gl-w-full"> + <pre + v-safe-html="jobTrace" + class="gl-bg-gray-900 gl-text-white" + :data-testid="isVisibleId" + ></pre> + </gl-collapse> + </div> </div> </template> diff --git a/app/assets/javascripts/vue_merge_request_widget/components/approvals/approvals.vue b/app/assets/javascripts/vue_merge_request_widget/components/approvals/approvals.vue index ad78de8728f..95fa01c23f1 100644 --- a/app/assets/javascripts/vue_merge_request_widget/components/approvals/approvals.vue +++ b/app/assets/javascripts/vue_merge_request_widget/components/approvals/approvals.vue @@ -7,7 +7,6 @@ import { HTTP_STATUS_UNAUTHORIZED } from '~/lib/utils/http_status'; import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import { s__, __, sprintf } from '~/locale'; import { getIdFromGraphQLId } from '~/graphql_shared/utils'; -import eventHub from '../../event_hub'; import approvalsMixin from '../../mixins/approvals'; import StateContainer from '../state_container.vue'; import { INVALID_RULES_DOCS_PATH } from '../../constants'; @@ -215,11 +214,6 @@ export default { this.clearError(); return serviceFn() .then(() => { - if (!window.gon?.features?.realtimeMrStatusChange) { - eventHub.$emit('MRWidgetUpdateRequested'); - eventHub.$emit('ApprovalUpdated'); - } - // TODO: Remove this line when we move to Apollo subscriptions this.$apollo.queries.approvals.refetch(); }) diff --git a/app/assets/javascripts/vue_merge_request_widget/components/states/ready_to_merge.vue b/app/assets/javascripts/vue_merge_request_widget/components/states/ready_to_merge.vue index fad0830388e..52cdafd4717 100644 --- a/app/assets/javascripts/vue_merge_request_widget/components/states/ready_to_merge.vue +++ b/app/assets/javascripts/vue_merge_request_widget/components/states/ready_to_merge.vue @@ -97,7 +97,7 @@ export default { return readyToMergeSubscription; }, skip() { - return !this.mr?.id || this.loading || !window.gon?.features?.realtimeMrStatusChange; + return !this.mr?.id || this.loading; }, variables() { return { diff --git a/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.vue b/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.vue index 9dc5bf77da7..af9e303594a 100644 --- a/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.vue +++ b/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.vue @@ -133,7 +133,7 @@ export default { return getStateSubscription; }, skip() { - return !this.mr?.id || this.loading || !window.gon?.features?.realtimeMrStatusChange; + return !this.mr?.id || this.loading; }, variables() { return { diff --git a/app/assets/stylesheets/highlight/themes/dark.scss b/app/assets/stylesheets/highlight/themes/dark.scss index 02469cf5165..9ad7c1b796c 100644 --- a/app/assets/stylesheets/highlight/themes/dark.scss +++ b/app/assets/stylesheets/highlight/themes/dark.scss @@ -134,10 +134,6 @@ $dark-il: #de935f; // Line numbers - .file-line-num { - @include line-link($white, 'link'); - } - .file-line-blame { @include line-link($white, 'git'); } diff --git a/app/assets/stylesheets/highlight/themes/monokai.scss b/app/assets/stylesheets/highlight/themes/monokai.scss index 30d04b4002e..b1d89d3c253 100644 --- a/app/assets/stylesheets/highlight/themes/monokai.scss +++ b/app/assets/stylesheets/highlight/themes/monokai.scss @@ -125,10 +125,6 @@ $monokai-gh: #75715e; @include hljs-override('params', $monokai-nb); // Line numbers - .file-line-num { - @include line-link($white, 'link'); - } - .file-line-blame { @include line-link($white, 'git'); } diff --git a/app/assets/stylesheets/highlight/themes/none.scss b/app/assets/stylesheets/highlight/themes/none.scss index 8339d7eff80..4762aae1d12 100644 --- a/app/assets/stylesheets/highlight/themes/none.scss +++ b/app/assets/stylesheets/highlight/themes/none.scss @@ -24,10 +24,6 @@ } // Line numbers - .file-line-num { - @include line-link($black, 'link'); - } - .file-line-blame { @include line-link($black, 'git'); } diff --git a/app/assets/stylesheets/highlight/themes/solarized-dark.scss b/app/assets/stylesheets/highlight/themes/solarized-dark.scss index 075510e6e5f..7958959bfc3 100644 --- a/app/assets/stylesheets/highlight/themes/solarized-dark.scss +++ b/app/assets/stylesheets/highlight/themes/solarized-dark.scss @@ -128,10 +128,6 @@ $solarized-dark-il: #2aa198; @include hljs-override('params', $solarized-dark-nb); // Line numbers - .file-line-num { - @include line-link($white, 'link'); - } - .file-line-blame { @include line-link($white, 'git'); } diff --git a/app/assets/stylesheets/highlight/themes/solarized-light.scss b/app/assets/stylesheets/highlight/themes/solarized-light.scss index 4e244ed7420..f156077c64d 100644 --- a/app/assets/stylesheets/highlight/themes/solarized-light.scss +++ b/app/assets/stylesheets/highlight/themes/solarized-light.scss @@ -118,10 +118,6 @@ $solarized-light-il: #2aa198; @include hljs-override('params', $solarized-light-nb); // Line numbers - .file-line-num { - @include line-link($black, 'link'); - } - .file-line-blame { @include line-link($black, 'git'); } diff --git a/app/assets/stylesheets/highlight/white_base.scss b/app/assets/stylesheets/highlight/white_base.scss index 969a6665634..14524e163b2 100644 --- a/app/assets/stylesheets/highlight/white_base.scss +++ b/app/assets/stylesheets/highlight/white_base.scss @@ -94,10 +94,6 @@ $white-gc-bg: #eaf2f5; } // Line numbers -.file-line-num { - @include line-link($black, 'link'); -} - .file-line-blame { @include line-link($black, 'git'); } diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index f858a0e5cf7..eda72400f17 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -15,7 +15,11 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController feature_category :system_access def handle_omniauth - omniauth_flow(Gitlab::Auth::OAuth) + if ::AuthHelper.saml_providers.include?(oauth['provider'].to_sym) + saml + else + omniauth_flow(Gitlab::Auth::OAuth) + end end AuthHelper.providers_for_base_controller.each do |provider| diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 77ff69c669d..60f619a8d20 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -44,7 +44,6 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo push_frontend_feature_flag(:deprecate_vulnerabilities_feedback, @project) push_frontend_feature_flag(:moved_mr_sidebar, project) push_frontend_feature_flag(:mr_experience_survey, project) - push_frontend_feature_flag(:realtime_mr_status_change, project) push_frontend_feature_flag(:saved_replies, current_user) push_frontend_feature_flag(:code_quality_inline_drawer, project) push_frontend_feature_flag(:auto_merge_labels_mr_widget, project) diff --git a/app/graphql/graphql_triggers.rb b/app/graphql/graphql_triggers.rb index 7abd1258958..527eb50b644 100644 --- a/app/graphql/graphql_triggers.rb +++ b/app/graphql/graphql_triggers.rb @@ -48,8 +48,6 @@ module GraphqlTriggers end def self.merge_request_merge_status_updated(merge_request) - return unless Feature.enabled?(:realtime_mr_status_change, merge_request.project) - GitlabSchema.subscriptions.trigger( :merge_request_merge_status_updated, { issuable_id: merge_request.to_gid }, merge_request ) diff --git a/app/models/concerns/spammable.rb b/app/models/concerns/spammable.rb index 36a2242b5b5..8bed8b1211a 100644 --- a/app/models/concerns/spammable.rb +++ b/app/models/concerns/spammable.rb @@ -105,8 +105,12 @@ module Spammable _('issue') when MergeRequest _('merge request') + when Note + _('comment') when Snippet _('snippet') + when Note + _('comment') else self.class.model_name.human.downcase end @@ -145,9 +149,9 @@ module Spammable (changed & self.class.spammable_attrs.to_h.keys).any? end - def check_for_spam(action:, user:) - strong_memoize_with(:check_for_spam, action, user) do - Spam::SpamActionService.new(spammable: self, user: user, action: action).execute + def check_for_spam(user:, action:, extra_features: {}) + strong_memoize_with(:check_for_spam, user, action, extra_features) do + Spam::SpamActionService.new(spammable: self, user: user, action: action, extra_features: extra_features).execute end end diff --git a/app/models/note.rb b/app/models/note.rb index 5f48ec0b56c..09ff7ad3979 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -785,7 +785,7 @@ class Note < ApplicationRecord # Override method defined in Spammable # Wildcard argument because user: argument is not used def check_for_spam?(*) - return false if system? || !note_changed? || confidential? + return false if system? || !spammable_attribute_changed? || confidential? return false if noteable.try(:confidential?) == true || noteable.try(:public?) == false return false if noteable.try(:group)&.public? == false || project&.public? == false diff --git a/app/models/packages/nuget/metadatum.rb b/app/models/packages/nuget/metadatum.rb index 08276f87568..fae7728cccb 100644 --- a/app/models/packages/nuget/metadatum.rb +++ b/app/models/packages/nuget/metadatum.rb @@ -3,13 +3,14 @@ class Packages::Nuget::Metadatum < ApplicationRecord MAX_AUTHORS_LENGTH = 255 MAX_DESCRIPTION_LENGTH = 4000 + MAX_URL_LENGTH = 255 belongs_to :package, -> { where(package_type: :nuget) }, inverse_of: :nuget_metadatum validates :package, presence: true - validates :license_url, public_url: { allow_blank: true } - validates :project_url, public_url: { allow_blank: true } - validates :icon_url, public_url: { allow_blank: true } + validates :license_url, public_url: { allow_blank: true }, length: { maximum: MAX_URL_LENGTH } + validates :project_url, public_url: { allow_blank: true }, length: { maximum: MAX_URL_LENGTH } + validates :icon_url, public_url: { allow_blank: true }, length: { maximum: MAX_URL_LENGTH } validates :authors, presence: true, length: { maximum: MAX_AUTHORS_LENGTH } validates :description, presence: true, length: { maximum: MAX_DESCRIPTION_LENGTH } diff --git a/app/models/users/callout.rb b/app/models/users/callout.rb index 34a116c36be..38e518b6d3e 100644 --- a/app/models/users/callout.rb +++ b/app/models/users/callout.rb @@ -71,7 +71,8 @@ module Users repository_storage_limit_banner_alert_threshold: 69, # EE-only repository_storage_limit_banner_error_threshold: 70, # EE-only new_navigation_callout: 71, - code_suggestions_third_party_callout: 72 # EE-only + code_suggestions_third_party_callout: 72, # EE-only + namespace_over_storage_users_combined_alert: 73 # EE-only } validates :feature_name, diff --git a/app/models/users/group_callout.rb b/app/models/users/group_callout.rb index 03384b594d6..c5946197b6f 100644 --- a/app/models/users/group_callout.rb +++ b/app/models/users/group_callout.rb @@ -29,7 +29,8 @@ module Users repository_storage_limit_banner_info_threshold: 19, # EE-only repository_storage_limit_banner_warning_threshold: 20, # EE-only repository_storage_limit_banner_alert_threshold: 21, # EE-only - repository_storage_limit_banner_error_threshold: 22 # EE-only + repository_storage_limit_banner_error_threshold: 22, # EE-only + namespace_over_storage_users_combined_alert: 23 # EE-only } validates :group, presence: true diff --git a/app/services/error_tracking/collect_error_service.rb b/app/services/error_tracking/collect_error_service.rb deleted file mode 100644 index 8cb3793ba97..00000000000 --- a/app/services/error_tracking/collect_error_service.rb +++ /dev/null @@ -1,82 +0,0 @@ -# frozen_string_literal: true - -module ErrorTracking - class CollectErrorService < ::BaseService - include Gitlab::Utils::StrongMemoize - - def execute - error_repository.report_error( - name: exception['type'], - description: exception['value'], - actor: actor, - platform: event['platform'], - occurred_at: timestamp, - environment: event['environment'], - level: event['level'], - payload: event - ) - end - - private - - def error_repository - Gitlab::ErrorTracking::ErrorRepository.build(project) - end - - def event - @event ||= format_event(params[:event]) - end - - def format_event(event) - # Some SDK send exception payload as Array. For exmple Go lang SDK. - # We need to convert it to hash format we expect. - if event['exception'].is_a?(Array) - exception = event['exception'] - event['exception'] = { 'values' => exception } - end - - event - end - - def exception - strong_memoize(:exception) do - # Find the first exception that has a stacktrace since the first - # exception may not provide adequate context (e.g. in the Go SDK). - entries = event['exception']['values'] - entries.find { |x| x.key?('stacktrace') } || entries.first - end - end - - def stacktrace_frames - strong_memoize(:stacktrace_frames) do - exception.dig('stacktrace', 'frames') - end - end - - def actor - return event['transaction'] if event['transaction'].present? - - # Some SDKs do not have a transaction attribute. - # So we build it by combining function name and module name from - # the last item in stacktrace. - return unless stacktrace_frames.present? - - last_line = stacktrace_frames.last - - "#{last_line['function']}(#{last_line['module']})" - end - - def timestamp - return @timestamp if @timestamp - - @timestamp = (event['timestamp'] || Time.zone.now) - - # Some SDK send timestamp in numeric format like '1630945472.13'. - if @timestamp.to_s =~ /\A\d+(\.\d+)?\z/ - @timestamp = Time.zone.at(@timestamp.to_f) - end - - @timestamp - end - end -end diff --git a/app/services/issues/create_service.rb b/app/services/issues/create_service.rb index 4731a5dd39c..17b6866773e 100644 --- a/app/services/issues/create_service.rb +++ b/app/services/issues/create_service.rb @@ -47,7 +47,7 @@ module Issues end def before_create(issue) - Spam::SpamActionService.new(spammable: issue, user: current_user, action: :create).execute if perform_spam_check + issue.check_for_spam(user: current_user, action: :create) if perform_spam_check # current_user (defined in BaseService) is not available within run_after_commit block user = current_user diff --git a/app/services/issues/update_service.rb b/app/services/issues/update_service.rb index a17ca62ccab..7ad56d5a755 100644 --- a/app/services/issues/update_service.rb +++ b/app/services/issues/update_service.rb @@ -28,11 +28,7 @@ module Issues return if skip_spam_check || !perform_spam_check - Spam::SpamActionService.new( - spammable: issue, - user: current_user, - action: :update - ).execute + issue.check_for_spam(user: current_user, action: :update) end def change_work_item_type(issue) diff --git a/app/services/merge_requests/create_service.rb b/app/services/merge_requests/create_service.rb index a042e570132..9135a80c883 100644 --- a/app/services/merge_requests/create_service.rb +++ b/app/services/merge_requests/create_service.rb @@ -41,7 +41,7 @@ module MergeRequests # timeout, we do this before we attempt to save the merge request. merge_request.skip_ensure_merge_request_diff = true - Spam::SpamActionService.new(spammable: merge_request, user: current_user, action: :create).execute + merge_request.check_for_spam(user: current_user, action: :create) end def set_projects! diff --git a/app/services/merge_requests/update_service.rb b/app/services/merge_requests/update_service.rb index 123420d9af3..598dbaf93a9 100644 --- a/app/services/merge_requests/update_service.rb +++ b/app/services/merge_requests/update_service.rb @@ -211,7 +211,7 @@ module MergeRequests override :before_update def before_update(merge_request, skip_spam_check: false) - Spam::SpamActionService.new(spammable: merge_request, user: current_user, action: :update).execute unless skip_spam_check + merge_request.check_for_spam(user: current_user, action: :update) unless skip_spam_check end override :handle_quick_actions diff --git a/app/services/packages/nuget/update_package_from_metadata_service.rb b/app/services/packages/nuget/update_package_from_metadata_service.rb index 7153a9035b8..8e2679db31b 100644 --- a/app/services/packages/nuget/update_package_from_metadata_service.rb +++ b/app/services/packages/nuget/update_package_from_metadata_service.rb @@ -9,6 +9,9 @@ module Packages # used by ExclusiveLeaseGuard DEFAULT_LEASE_TIMEOUT = 1.hour.to_i.freeze SYMBOL_PACKAGE_IDENTIFIER = 'SymbolsPackage' + INVALID_METADATA_ERROR_MESSAGE = 'package name, version, authors and/or description not found in metadata' + INVALID_METADATA_ERROR_SYMBOL_MESSAGE = 'package name, version and/or description not found in metadata' + MISSING_MATCHING_PACKAGE_ERROR_MESSAGE = 'symbol package is invalid, matching package does not exist' InvalidMetadataError = Class.new(StandardError) @@ -17,7 +20,10 @@ module Packages end def execute - raise InvalidMetadataError, 'package name, version, authors and/or description not found in metadata' unless valid_metadata? + unless valid_metadata? + error_message = symbol_package? ? INVALID_METADATA_ERROR_SYMBOL_MESSAGE : INVALID_METADATA_ERROR_MESSAGE + raise InvalidMetadataError, error_message + end try_obtain_lease do @package_file.transaction do @@ -39,7 +45,7 @@ module Packages target_package = existing_package else if symbol_package? - raise InvalidMetadataError, 'symbol package is invalid, matching package does not exist' + raise InvalidMetadataError, MISSING_MATCHING_PACKAGE_ERROR_MESSAGE end update_linked_package @@ -67,7 +73,9 @@ module Packages end def valid_metadata? - [package_name, package_version, package_authors, package_description].all?(&:present?) + fields = [package_name, package_version, package_description] + fields << package_authors unless symbol_package? + fields.all?(&:present?) end def link_to_existing_package diff --git a/app/services/snippets/create_service.rb b/app/services/snippets/create_service.rb index 111c6211dab..569b8b76518 100644 --- a/app/services/snippets/create_service.rb +++ b/app/services/snippets/create_service.rb @@ -19,12 +19,7 @@ module Snippets @snippet.author = current_user if perform_spam_check - Spam::SpamActionService.new( - spammable: @snippet, - user: current_user, - action: :create, - extra_features: { files: file_paths_to_commit } - ).execute + @snippet.check_for_spam(user: current_user, action: :create, extra_features: { files: file_paths_to_commit }) end if save_and_commit diff --git a/app/services/snippets/update_service.rb b/app/services/snippets/update_service.rb index 684ede1f2eb..662e31a93aa 100644 --- a/app/services/snippets/update_service.rb +++ b/app/services/snippets/update_service.rb @@ -23,12 +23,7 @@ module Snippets files = snippet.all_files.map { |f| { path: f } } + file_paths_to_commit if perform_spam_check - Spam::SpamActionService.new( - spammable: snippet, - user: current_user, - action: :update, - extra_features: { files: files } - ).execute + snippet.check_for_spam(user: current_user, action: :update, extra_features: { files: files }) end if save_and_commit(snippet) diff --git a/app/views/layouts/group.html.haml b/app/views/layouts/group.html.haml index 36e773ea1ae..c75b02aa6a6 100644 --- a/app/views/layouts/group.html.haml +++ b/app/views/layouts/group.html.haml @@ -9,6 +9,7 @@ - content_for :flash_message do = dispensable_render_if_exists "groups/storage_enforcement_alert", context: @group = dispensable_render_if_exists "shared/namespace_storage_limit_alert", context: @group + = dispensable_render_if_exists "shared/namespace_combined_storage_users_alert", context: @group - content_for :page_specific_javascripts do - if current_user diff --git a/app/views/layouts/project.html.haml b/app/views/layouts/project.html.haml index 9a7995090e3..4ecae875056 100644 --- a/app/views/layouts/project.html.haml +++ b/app/views/layouts/project.html.haml @@ -10,6 +10,7 @@ - content_for :flash_message do = dispensable_render_if_exists "projects/storage_enforcement_alert", context: @project = dispensable_render_if_exists "shared/namespace_storage_limit_alert", context: @project + = dispensable_render_if_exists "shared/namespace_combined_storage_users_alert", context: @project - content_for :project_javascripts do - project = @target_project || @project |