diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-23 21:15:39 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-23 21:15:39 +0300 |
commit | 68caf5fd883a7fd5a3395c2e5ae2a5c511445613 (patch) | |
tree | 7a63a675e90f9819e32dc9927d3a1fae6e3ffe75 /lib | |
parent | 003d7f2a09668af85f94e48ed49d60862b96d8f8 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/helpers.rb | 2 | ||||
-rw-r--r-- | lib/api/helpers/merge_requests_helpers.rb | 3 | ||||
-rw-r--r-- | lib/api/projects.rb | 23 | ||||
-rw-r--r-- | lib/bulk_imports/clients/http.rb | 2 | ||||
-rw-r--r-- | lib/bulk_imports/error.rb | 9 |
5 files changed, 37 insertions, 2 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index aadcbe38b15..74c740f47cc 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -683,6 +683,8 @@ module API finder_params[:user] = params.delete(:user) if params[:user] finder_params[:id_after] = sanitize_id_param(params[:id_after]) if params[:id_after] finder_params[:id_before] = sanitize_id_param(params[:id_before]) if params[:id_before] + finder_params[:updated_after] = declared_params[:updated_after] if declared_params[:updated_after] + finder_params[:updated_before] = declared_params[:updated_before] if declared_params[:updated_before] finder_params end diff --git a/lib/api/helpers/merge_requests_helpers.rb b/lib/api/helpers/merge_requests_helpers.rb index ee3bb49c97f..0a0d70520ef 100644 --- a/lib/api/helpers/merge_requests_helpers.rb +++ b/lib/api/helpers/merge_requests_helpers.rb @@ -105,6 +105,9 @@ module API documentation: { example: '2019-03-15T08:00:00Z' } optional :environment, desc: 'Returns merge requests deployed to the given environment', documentation: { example: '2019-03-15T08:00:00Z' } + optional :approved, type: String, + values: %w[yes no], + desc: 'Filters merge requests by their `approved` status. `yes` returns only approved merge requests. `no` returns only non-approved merge requests.' end params :optional_scope_param do diff --git a/lib/api/projects.rb b/lib/api/projects.rb index b2e144ee165..697c2a7e214 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -40,6 +40,23 @@ module API attrs.delete(:repository_storage) unless can?(current_user, :use_project_statistics_filters) end + def validate_updated_at_order_and_filter! + return unless filter_by_updated_at? && provided_order_is_not_updated_at? + + # This is necessary as not pairing this filter and ordering will produce an inneficient query + bad_request!('`updated_at` filter and `updated_at` sorting must be paired') + end + + def provided_order_is_not_updated_at? + order_by_param = declared_params[:order_by] + + order_by_param.present? && order_by_param.to_s != 'updated_at' + end + + def filter_by_updated_at? + declared_params[:updated_before].present? || declared_params[:updated_after].present? + end + def verify_statistics_order_by_projects! return unless Helpers::ProjectsHelpers::STATISTICS_SORT_PARAMS.include?(params[:order_by]) @@ -144,6 +161,8 @@ module API optional :repository_storage, type: String, desc: 'Which storage shard the repository is on. Available only to admins' optional :topic, type: Array[String], coerce_with: ::API::Validations::Types::CommaSeparatedToArray.coerce, desc: 'Comma-separated list of topics. Limit results to projects having all topics' optional :topic_id, type: Integer, desc: 'Limit results to projects with the assigned topic given by the topic ID' + optional :updated_before, type: DateTime, desc: 'Return projects updated before the specified datetime. Format: ISO 8601 YYYY-MM-DDTHH:MM:SSZ' + optional :updated_after, type: DateTime, desc: 'Return projects updated after the specified datetime. Format: ISO 8601 YYYY-MM-DDTHH:MM:SSZ' use :optional_filter_params_ee end @@ -261,6 +280,9 @@ module API desc 'Get a list of visible projects for authenticated user' do success code: 200, model: Entities::BasicProjectDetails + failure [ + { code: 400, message: 'Bad request' } + ] tags %w[projects] is_array true end @@ -272,6 +294,7 @@ module API # TODO: Set higher urgency https://gitlab.com/gitlab-org/gitlab/-/issues/211495 get feature_category: :projects, urgency: :low do validate_projects_api_rate_limit_for_unauthenticated_users! + validate_updated_at_order_and_filter! present_projects load_projects end diff --git a/lib/bulk_imports/clients/http.rb b/lib/bulk_imports/clients/http.rb index 6efee83a0dd..616ab8754b4 100644 --- a/lib/bulk_imports/clients/http.rb +++ b/lib/bulk_imports/clients/http.rb @@ -165,6 +165,8 @@ module BulkImports raise ::BulkImports::NetworkError.new("Unsuccessful response #{response.code} from #{response.request.path.path}. Body: #{response.parsed_response}", response: response) + rescue Gitlab::HTTP::BlockedUrlError => e + raise e rescue *Gitlab::HTTP::HTTP_ERRORS => e raise ::BulkImports::NetworkError, e end diff --git a/lib/bulk_imports/error.rb b/lib/bulk_imports/error.rb index 009fa02a72a..fb72cb61de0 100644 --- a/lib/bulk_imports/error.rb +++ b/lib/bulk_imports/error.rb @@ -3,8 +3,7 @@ module BulkImports class Error < StandardError def self.unsupported_gitlab_version - self.new("Unsupported GitLab version. Source instance must run GitLab version #{BulkImport::MIN_MAJOR_VERSION} " \ - "or later.") + self.new("Unsupported GitLab version. Minimum supported version is #{BulkImport::MIN_MAJOR_VERSION}.") end def self.scope_validation_failure @@ -19,5 +18,11 @@ module BulkImports def self.destination_full_path_validation_failure(full_path) self.new("Import aborted as '#{full_path}' already exists. Change the destination and try again.") end + + def self.setting_not_enabled + self.new("Group import disabled on source or destination instance. " \ + "Ask an administrator to enable it on both instances and try again." + ) + end end end |