diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-14 09:08:19 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-14 09:08:19 +0000 |
commit | 02ab65d49fc94be7c91e511899762236c122977d (patch) | |
tree | 4d4bf4ec54a95a0d73e039fa1410ea841156ffb2 /lib | |
parent | 4411353300cf8219d2b899785bc5103c549ba8cf (diff) | |
download | gitlab-ce-02ab65d49fc94be7c91e511899762236c122977d.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
14 files changed, 170 insertions, 3 deletions
diff --git a/lib/gitlab/background_migration/backfill_version_data_from_gitaly.rb b/lib/gitlab/background_migration/backfill_version_data_from_gitaly.rb new file mode 100644 index 00000000000..83d60d2db19 --- /dev/null +++ b/lib/gitlab/background_migration/backfill_version_data_from_gitaly.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Gitlab + module BackgroundMigration + # rubocop: disable Style/Documentation + class BackfillVersionDataFromGitaly + def perform(issue_id) + end + end + end +end + +Gitlab::BackgroundMigration::BackfillVersionDataFromGitaly.prepend_if_ee('EE::Gitlab::BackgroundMigration::BackfillVersionDataFromGitaly') diff --git a/lib/gitlab/background_migration/generate_gitlab_subscriptions.rb b/lib/gitlab/background_migration/generate_gitlab_subscriptions.rb new file mode 100644 index 00000000000..85bcf8558f2 --- /dev/null +++ b/lib/gitlab/background_migration/generate_gitlab_subscriptions.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Gitlab + module BackgroundMigration + # rubocop: disable Style/Documentation + class GenerateGitlabSubscriptions + def perform(start_id, stop_id) + end + end + end +end + +Gitlab::BackgroundMigration::GenerateGitlabSubscriptions.prepend_if_ee('EE::Gitlab::BackgroundMigration::GenerateGitlabSubscriptions') diff --git a/lib/gitlab/background_migration/migrate_approver_to_approval_rules.rb b/lib/gitlab/background_migration/migrate_approver_to_approval_rules.rb new file mode 100644 index 00000000000..27b984b4531 --- /dev/null +++ b/lib/gitlab/background_migration/migrate_approver_to_approval_rules.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Gitlab + module BackgroundMigration + # rubocop: disable Style/Documentation + class MigrateApproverToApprovalRules + # @param target_type [String] class of target, either 'MergeRequest' or 'Project' + # @param target_id [Integer] id of target + def perform(target_type, target_id, sync_code_owner_rule: true) + end + end + end +end + +Gitlab::BackgroundMigration::MigrateApproverToApprovalRules.prepend_if_ee('EE::Gitlab::BackgroundMigration::MigrateApproverToApprovalRules') diff --git a/lib/gitlab/background_migration/migrate_approver_to_approval_rules_check_progress.rb b/lib/gitlab/background_migration/migrate_approver_to_approval_rules_check_progress.rb new file mode 100644 index 00000000000..053b7363286 --- /dev/null +++ b/lib/gitlab/background_migration/migrate_approver_to_approval_rules_check_progress.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Gitlab + module BackgroundMigration + # rubocop: disable Style/Documentation + class MigrateApproverToApprovalRulesCheckProgress + def perform + end + end + end +end + +Gitlab::BackgroundMigration::MigrateApproverToApprovalRulesCheckProgress.prepend_if_ee('EE::Gitlab::BackgroundMigration::MigrateApproverToApprovalRulesCheckProgress') diff --git a/lib/gitlab/background_migration/migrate_approver_to_approval_rules_in_batch.rb b/lib/gitlab/background_migration/migrate_approver_to_approval_rules_in_batch.rb new file mode 100644 index 00000000000..130f97b09d7 --- /dev/null +++ b/lib/gitlab/background_migration/migrate_approver_to_approval_rules_in_batch.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Gitlab + module BackgroundMigration + # rubocop: disable Style/Documentation + class MigrateApproverToApprovalRulesInBatch + def perform(start_id, end_id) + end + end + end +end + +Gitlab::BackgroundMigration::MigrateApproverToApprovalRulesInBatch.prepend_if_ee('EE::Gitlab::BackgroundMigration::MigrateApproverToApprovalRulesInBatch') diff --git a/lib/gitlab/background_migration/move_epic_issues_after_epics.rb b/lib/gitlab/background_migration/move_epic_issues_after_epics.rb new file mode 100644 index 00000000000..dc982e703d1 --- /dev/null +++ b/lib/gitlab/background_migration/move_epic_issues_after_epics.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Gitlab + module BackgroundMigration + # rubocop: disable Style/Documentation + class MoveEpicIssuesAfterEpics + def perform(start_id, stop_id) + end + end + end +end + +Gitlab::BackgroundMigration::MoveEpicIssuesAfterEpics.prepend_if_ee('EE::Gitlab::BackgroundMigration::MoveEpicIssuesAfterEpics') diff --git a/lib/gitlab/background_migration/populate_any_approval_rule_for_merge_requests.rb b/lib/gitlab/background_migration/populate_any_approval_rule_for_merge_requests.rb new file mode 100644 index 00000000000..c3c0db2495c --- /dev/null +++ b/lib/gitlab/background_migration/populate_any_approval_rule_for_merge_requests.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Gitlab + module BackgroundMigration + # This background migration creates any approver rule records according + # to the given merge request IDs range. A _single_ INSERT is issued for the given range. + class PopulateAnyApprovalRuleForMergeRequests + def perform(from_id, to_id) + end + end + end +end + +Gitlab::BackgroundMigration::PopulateAnyApprovalRuleForMergeRequests.prepend_if_ee('EE::Gitlab::BackgroundMigration::PopulateAnyApprovalRuleForMergeRequests') diff --git a/lib/gitlab/background_migration/populate_any_approval_rule_for_projects.rb b/lib/gitlab/background_migration/populate_any_approval_rule_for_projects.rb new file mode 100644 index 00000000000..2243c7531c0 --- /dev/null +++ b/lib/gitlab/background_migration/populate_any_approval_rule_for_projects.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Gitlab + module BackgroundMigration + # This background migration creates any approver rule records according + # to the given project IDs range. A _single_ INSERT is issued for the given range. + class PopulateAnyApprovalRuleForProjects + def perform(from_id, to_id) + end + end + end +end + +Gitlab::BackgroundMigration::PopulateAnyApprovalRuleForProjects.prepend_if_ee('EE::Gitlab::BackgroundMigration::PopulateAnyApprovalRuleForProjects') diff --git a/lib/gitlab/background_migration/prune_orphaned_geo_events.rb b/lib/gitlab/background_migration/prune_orphaned_geo_events.rb new file mode 100644 index 00000000000..8b16db8be35 --- /dev/null +++ b/lib/gitlab/background_migration/prune_orphaned_geo_events.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true +# +# rubocop:disable Style/Documentation + +# This job is added to fix https://gitlab.com/gitlab-org/gitlab/issues/30229 +# It's not used anywhere else. +# Can be removed in GitLab 13.* +module Gitlab + module BackgroundMigration + class PruneOrphanedGeoEvents + def perform(table_name) + end + end + end +end + +Gitlab::BackgroundMigration::PruneOrphanedGeoEvents.prepend_if_ee('EE::Gitlab::BackgroundMigration::PruneOrphanedGeoEvents') diff --git a/lib/gitlab/background_migration/update_authorized_keys_file_since.rb b/lib/gitlab/background_migration/update_authorized_keys_file_since.rb new file mode 100644 index 00000000000..dd80d4bab1a --- /dev/null +++ b/lib/gitlab/background_migration/update_authorized_keys_file_since.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Gitlab + module BackgroundMigration + # rubocop: disable Style/Documentation + class UpdateAuthorizedKeysFileSince + def perform(cutoff_datetime) + end + end + end +end + +Gitlab::BackgroundMigration::UpdateAuthorizedKeysFileSince.prepend_if_ee('EE::Gitlab::BackgroundMigration::UpdateAuthorizedKeysFileSince') diff --git a/lib/gitlab/background_migration/update_vulnerability_confidence.rb b/lib/gitlab/background_migration/update_vulnerability_confidence.rb new file mode 100644 index 00000000000..6ffaa836f3c --- /dev/null +++ b/lib/gitlab/background_migration/update_vulnerability_confidence.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Gitlab + module BackgroundMigration + # rubocop: disable Style/Documentation + class UpdateVulnerabilityConfidence + def perform(start_id, stop_id) + end + end + end +end + +Gitlab::BackgroundMigration::UpdateVulnerabilityConfidence.prepend_if_ee('EE::Gitlab::BackgroundMigration::UpdateVulnerabilityConfidence') diff --git a/lib/gitlab/ci/config/entry/includes.rb b/lib/gitlab/ci/config/entry/includes.rb index 43e74dfd628..24d0e27e3a7 100644 --- a/lib/gitlab/ci/config/entry/includes.rb +++ b/lib/gitlab/ci/config/entry/includes.rb @@ -12,6 +12,15 @@ module Gitlab validations do validates :config, array_or_string: true + + validate do + next unless opt(:max_size) + next unless config.is_a?(Array) + + if config.size > opt(:max_size) + errors.add(:config, "is too long (maximum is #{opt(:max_size)})") + end + end end def self.aspects diff --git a/lib/gitlab/email/attachment_uploader.rb b/lib/gitlab/email/attachment_uploader.rb index 3323ce60158..0a14a909e31 100644 --- a/lib/gitlab/email/attachment_uploader.rb +++ b/lib/gitlab/email/attachment_uploader.rb @@ -9,7 +9,7 @@ module Gitlab @message = message end - def execute(project) + def execute(upload_parent:, uploader_class:) attachments = [] message.attachments.each do |attachment| @@ -23,7 +23,7 @@ module Gitlab content_type: attachment.content_type } - uploader = UploadService.new(project, file).execute + uploader = UploadService.new(upload_parent, file, uploader_class).execute attachments << uploader.to_h if uploader ensure tmp.close! diff --git a/lib/gitlab/email/handler/reply_processing.rb b/lib/gitlab/email/handler/reply_processing.rb index 6b7686cd405..312a9fdfbae 100644 --- a/lib/gitlab/email/handler/reply_processing.rb +++ b/lib/gitlab/email/handler/reply_processing.rb @@ -41,13 +41,20 @@ module Gitlab end def add_attachments(reply) - attachments = Email::AttachmentUploader.new(mail).execute(project) + attachments = Email::AttachmentUploader.new(mail).execute(upload_params) reply + attachments.map do |link| "\n\n#{link[:markdown]}" end.join end + def upload_params + { + upload_parent: project, + uploader_class: FileUploader + } + end + def validate_permission!(permission) raise UserNotFoundError unless author raise UserBlockedError if author.blocked? |