diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-03 21:08:05 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-03 21:08:05 +0000 |
commit | 2eff77c2efe8ad71796561cae3bcd993b9065721 (patch) | |
tree | 964b2537abbfa9b8c5290ca82327003be52417e3 /lib | |
parent | 8f9307985ea047abb5b8a7c6c56bb644e0b7c363 (diff) | |
download | gitlab-ce-2eff77c2efe8ad71796561cae3bcd993b9065721.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
24 files changed, 73 insertions, 77 deletions
diff --git a/lib/api/draft_notes.rb b/lib/api/draft_notes.rb index ece4e1a6584..0cf0f43a839 100644 --- a/lib/api/draft_notes.rb +++ b/lib/api/draft_notes.rb @@ -16,6 +16,10 @@ module API def load_draft_notes(params:) merge_request(params: params).draft_notes.authored_by(current_user) end + + def get_draft_note(params:) + load_draft_notes(params: params).find(params[:draft_note_id]) + end end resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do @@ -34,6 +38,28 @@ module API get ":id/merge_requests/:merge_request_iid/draft_notes", feature_category: :code_review_workflow do present load_draft_notes(params: params), with: Entities::DraftNote end + + desc "Get a single draft note" do + success Entities::DraftNote + failure [ + { code: 401, message: 'Unauthorized' }, + { code: 404, message: 'Not found' } + ] + end + params do + requires :id, type: String, desc: "The ID of a project" + requires :merge_request_iid, type: Integer, desc: "The ID of a merge request" + requires :draft_note_id, type: Integer, desc: "The ID of a draft note" + end + get ":id/merge_requests/:merge_request_iid/draft_notes/:draft_note_id", feature_category: :code_review_workflow do + draft_note = get_draft_note(params: params) + + if draft_note + present draft_note, with: Entities::DraftNote + else + not_found!("Draft Note") + end + end end end end diff --git a/lib/atlassian/jira_issue_key_extractor.rb b/lib/atlassian/jira_issue_key_extractor.rb index f1b432787ac..968e8b0f82e 100644 --- a/lib/atlassian/jira_issue_key_extractor.rb +++ b/lib/atlassian/jira_issue_key_extractor.rb @@ -2,8 +2,8 @@ module Atlassian class JiraIssueKeyExtractor - def self.has_keys?(*text) - new(*text).issue_keys.any? + def self.has_keys?(...) + new(...).issue_keys.any? end def initialize(*text) diff --git a/lib/bulk_imports/clients/graphql.rb b/lib/bulk_imports/clients/graphql.rb index a9f908a4247..b8c80886a60 100644 --- a/lib/bulk_imports/clients/graphql.rb +++ b/lib/bulk_imports/clients/graphql.rb @@ -34,10 +34,10 @@ module BulkImports @compatible_instance_version = false end - def execute(*args) + def execute(...) validate_instance_version! - client.execute(*args) + client.execute(...) end def options(extra = {}) diff --git a/lib/gitlab/allowable.rb b/lib/gitlab/allowable.rb index 4518c8a862c..879247d0174 100644 --- a/lib/gitlab/allowable.rb +++ b/lib/gitlab/allowable.rb @@ -2,8 +2,8 @@ module Gitlab module Allowable - def can?(*args) - Ability.allowed?(*args) + def can?(...) + Ability.allowed?(...) end end end diff --git a/lib/gitlab/auth/ldap/adapter.rb b/lib/gitlab/auth/ldap/adapter.rb index 9aedc131e92..0201f1f8725 100644 --- a/lib/gitlab/auth/ldap/adapter.rb +++ b/lib/gitlab/auth/ldap/adapter.rb @@ -33,8 +33,8 @@ module Gitlab users_search(options) end - def user(*args) - users(*args).first + def user(...) + users(...).first end def dn_matches_filter?(dn, filter) diff --git a/lib/gitlab/ci/config/external/mapper/base.rb b/lib/gitlab/ci/config/external/mapper/base.rb index d2f56d0b8f6..d898ddb356c 100644 --- a/lib/gitlab/ci/config/external/mapper/base.rb +++ b/lib/gitlab/ci/config/external/mapper/base.rb @@ -11,9 +11,9 @@ module Gitlab @context = context end - def process(*args) + def process(...) context.logger.instrument(mapper_instrumentation_key) do - process_without_instrumentation(*args) + process_without_instrumentation(...) end end diff --git a/lib/gitlab/ci/config/yaml/tags/reference.rb b/lib/gitlab/ci/config/yaml/tags/reference.rb index 45787077c91..5ecab033109 100644 --- a/lib/gitlab/ci/config/yaml/tags/reference.rb +++ b/lib/gitlab/ci/config/yaml/tags/reference.rb @@ -16,7 +16,7 @@ module Gitlab def valid? data[:seq].is_a?(Array) && !data[:seq].empty? && - data[:seq].all? { |identifier| identifier.is_a?(String) } + data[:seq].all?(String) end private diff --git a/lib/gitlab/config/entry/validators.rb b/lib/gitlab/config/entry/validators.rb index 9e6a3d86e92..fad2260d818 100644 --- a/lib/gitlab/config/entry/validators.rb +++ b/lib/gitlab/config/entry/validators.rb @@ -98,7 +98,7 @@ module Gitlab private def validate_array_of_hashes(value) - value.is_a?(Array) && value.all? { |obj| obj.is_a?(Hash) } + value.is_a?(Array) && value.all?(Hash) end end diff --git a/lib/gitlab/database/migrations/background_migration_helpers.rb b/lib/gitlab/database/migrations/background_migration_helpers.rb index 25e75a10bb3..60df3370046 100644 --- a/lib/gitlab/database/migrations/background_migration_helpers.rb +++ b/lib/gitlab/database/migrations/background_migration_helpers.rb @@ -200,11 +200,14 @@ module Gitlab end end + # rubocop: disable Style/ArgumentsForwarding + # Reason: the default argument will not apply if we just forward via `...` def migrate_in(*args, coordinator: coordinator_for_tracking_database) with_migration_context do coordinator.perform_in(*args) end end + # rubocop: enable Style/ArgumentsForwarding def delete_queued_jobs(class_name) coordinator_for_tracking_database.steal(class_name) do |job| diff --git a/lib/gitlab/dependency_linker/base_linker.rb b/lib/gitlab/dependency_linker/base_linker.rb index 6d114de8ae8..203cee1fd5e 100644 --- a/lib/gitlab/dependency_linker/base_linker.rb +++ b/lib/gitlab/dependency_linker/base_linker.rb @@ -13,8 +13,8 @@ module Gitlab Gitlab::FileDetector.type_of(blob_name) == file_type end - def self.link(*args) - new(*args).link + def self.link(...) + new(...).link end attr_accessor :plain_text, :highlighted_text diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index ad49e9e7221..678e298c378 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -465,9 +465,9 @@ module Gitlab end # Returns the SHA of the most recent common ancestor of +from+ and +to+ - def merge_base(*commits) + def merge_base(...) wrapped_gitaly_errors do - gitaly_repository_client.find_merge_base(*commits) + gitaly_repository_client.find_merge_base(...) end end @@ -720,9 +720,9 @@ module Gitlab raise DeleteBranchError, e end - def delete_refs(*ref_names) + def delete_refs(...) wrapped_gitaly_errors do - gitaly_delete_refs(*ref_names) + gitaly_delete_refs(...) end end diff --git a/lib/gitlab/gitaly_client/server_service.rb b/lib/gitlab/gitaly_client/server_service.rb index 48fd0e66354..36bda67c26e 100644 --- a/lib/gitlab/gitaly_client/server_service.rb +++ b/lib/gitlab/gitaly_client/server_service.rb @@ -26,19 +26,6 @@ module Gitlab storage_specific(disk_statistics) end - def readiness_check - request = Gitaly::ReadinessCheckRequest.new(timeout: GitalyClient.medium_timeout) - response = GitalyClient.call(@storage, :server_service, :readiness_check, request, timeout: GitalyClient.default_timeout) - - return { success: true } if response.ok_response - - failed_checks = response.failure_response.failed_checks.map do |failed_check| - ["#{failed_check.name}: #{failed_check.error_message}"] - end - - { success: false, message: failed_checks.join("\n") } - end - private def storage_specific(response) diff --git a/lib/gitlab/github_import/markdown_text.rb b/lib/gitlab/github_import/markdown_text.rb index 2424b3e8c1f..8e9d6d8dd50 100644 --- a/lib/gitlab/github_import/markdown_text.rb +++ b/lib/gitlab/github_import/markdown_text.rb @@ -16,8 +16,8 @@ module Gitlab PULL_REF_MATCHER = '%{github_url}/%{import_source}/pull' class << self - def format(*args) - new(*args).to_s + def format(...) + new(...).to_s end # Links like `https://domain.github.com/<namespace>/<project>/pull/<iid>` needs to be converted diff --git a/lib/gitlab/graphql/authorize/authorize_resource.rb b/lib/gitlab/graphql/authorize/authorize_resource.rb index 884fc85c4ec..983bdb9c0a2 100644 --- a/lib/gitlab/graphql/authorize/authorize_resource.rb +++ b/lib/gitlab/graphql/authorize/authorize_resource.rb @@ -67,8 +67,8 @@ module Gitlab self.class.authorization.ok?(object, current_user) end - def raise_resource_not_available_error!(*args) - self.class.raise_resource_not_available_error!(*args) + def raise_resource_not_available_error!(...) + self.class.raise_resource_not_available_error!(...) end end end diff --git a/lib/gitlab/health_checks/gitaly_check.rb b/lib/gitlab/health_checks/gitaly_check.rb index 2bd8ea711b5..f5f142c251f 100644 --- a/lib/gitlab/health_checks/gitaly_check.rb +++ b/lib/gitlab/health_checks/gitaly_check.rb @@ -27,35 +27,17 @@ module Gitlab end def check(storage_name) - storage_healthy = healthy(storage_name) - unless storage_healthy[:success] - return HealthChecks::Result.new( - name, - storage_healthy[:success], - storage_healthy[:message], - shard: storage_name - ) - end + serv = Gitlab::GitalyClient::HealthCheckService.new(storage_name) + result = serv.check - storage_ready = ready(storage_name) HealthChecks::Result.new( name, - storage_ready[:success], - storage_ready[:message], + result[:success], + result[:message], shard: storage_name ) end - def healthy(storage_name) - serv = Gitlab::GitalyClient::HealthCheckService.new(storage_name) - serv.check - end - - def ready(storage_name) - serv = Gitlab::GitalyClient::ServerService.new(storage_name) - serv.readiness_check - end - private def metric_prefix diff --git a/lib/gitlab/i18n/translation_entry.rb b/lib/gitlab/i18n/translation_entry.rb index f3cca97950d..6623d42f526 100644 --- a/lib/gitlab/i18n/translation_entry.rb +++ b/lib/gitlab/i18n/translation_entry.rb @@ -65,7 +65,7 @@ module Gitlab end def translations_have_multiple_lines? - translation_entries.any? { |translation| translation.is_a?(Array) } + translation_entries.any?(Array) end def msgid_contains_unescaped_chars? diff --git a/lib/gitlab/import_export/base/object_builder.rb b/lib/gitlab/import_export/base/object_builder.rb index 7dee0f783cc..0f24492ed3c 100644 --- a/lib/gitlab/import_export/base/object_builder.rb +++ b/lib/gitlab/import_export/base/object_builder.rb @@ -15,8 +15,8 @@ module Gitlab LRU_CACHE_SIZE = 1000 class ObjectBuilder - def self.build(*args) - new(*args).find + def self.build(...) + new(...).find end def initialize(klass, attributes) diff --git a/lib/gitlab/metrics/dashboard/url.rb b/lib/gitlab/metrics/dashboard/url.rb index d4f779ad79d..bdd28744137 100644 --- a/lib/gitlab/metrics/dashboard/url.rb +++ b/lib/gitlab/metrics/dashboard/url.rb @@ -100,8 +100,8 @@ module Gitlab end # Builds a metrics dashboard url based on the passed in arguments - def build_dashboard_url(*args) - Gitlab::Routing.url_helpers.metrics_dashboard_namespace_project_environment_url(*args) + def build_dashboard_url(...) + Gitlab::Routing.url_helpers.metrics_dashboard_namespace_project_environment_url(...) end private diff --git a/lib/gitlab/nav/top_nav_view_model_builder.rb b/lib/gitlab/nav/top_nav_view_model_builder.rb index 8cb2729ff61..10b841f777e 100644 --- a/lib/gitlab/nav/top_nav_view_model_builder.rb +++ b/lib/gitlab/nav/top_nav_view_model_builder.rb @@ -11,12 +11,12 @@ module Gitlab # Using delegate hides the stacktrace for some errors, so we choose to be explicit. # https://gitlab.com/gitlab-org/gitlab/-/merge_requests/62047#note_579031091 - def add_primary_menu_item(**args) - @menu_builder.add_primary_menu_item(**args) + def add_primary_menu_item(...) + @menu_builder.add_primary_menu_item(...) end - def add_secondary_menu_item(**args) - @menu_builder.add_secondary_menu_item(**args) + def add_secondary_menu_item(...) + @menu_builder.add_secondary_menu_item(...) end def add_shortcut(**args) diff --git a/lib/gitlab/omniauth_initializer.rb b/lib/gitlab/omniauth_initializer.rb index b78cd2a6b95..fb7ffa03d0e 100644 --- a/lib/gitlab/omniauth_initializer.rb +++ b/lib/gitlab/omniauth_initializer.rb @@ -69,8 +69,8 @@ module Gitlab private - def add_provider_to_devise(*args) - @devise_config.omniauth(*args) + def add_provider_to_devise(...) + @devise_config.omniauth(...) end def arguments_for(provider) diff --git a/lib/gitlab/push_options.rb b/lib/gitlab/push_options.rb index 8a1dcc083e8..28d195238ea 100644 --- a/lib/gitlab/push_options.rb +++ b/lib/gitlab/push_options.rb @@ -46,8 +46,8 @@ module Gitlab @options = parse_options(options) end - def get(*args) - options.dig(*args) + def get(...) + options.dig(...) end # Allow #to_json serialization @@ -83,7 +83,7 @@ module Gitlab end def option_multi_value?(namespace, key) - MULTI_VALUE_OPTIONS.any? { |arr| arr == [namespace, key] } + MULTI_VALUE_OPTIONS.any?([namespace, key]) end def parse_option(option) diff --git a/lib/gitlab/utils/delegator_override.rb b/lib/gitlab/utils/delegator_override.rb index 3478931b170..446419378f8 100644 --- a/lib/gitlab/utils/delegator_override.rb +++ b/lib/gitlab/utils/delegator_override.rb @@ -17,7 +17,7 @@ module Gitlab def delegator_override(*names) return unless Gitlab::Environment.static_verification? - raise TypeError unless names.all? { |n| n.is_a?(Symbol) } + raise TypeError unless names.all?(Symbol) DelegatorOverride.validator(self).add_allowlist(names) end diff --git a/lib/gitlab/view/presenter/base.rb b/lib/gitlab/view/presenter/base.rb index 2a57ca9ae02..cb7f0a18a88 100644 --- a/lib/gitlab/view/presenter/base.rb +++ b/lib/gitlab/view/presenter/base.rb @@ -59,9 +59,7 @@ module Gitlab end def presents(*target_classes, as: nil) - if target_classes.any? { |k| k.is_a?(Symbol) } - raise ArgumentError, "Unsupported target class type: #{target_classes}." - end + raise ArgumentError, "Unsupported target class type: #{target_classes}." if target_classes.any?(Symbol) if self < ::Gitlab::View::Presenter::Delegated target_classes.each { |k| delegator_target(k) } diff --git a/lib/tasks/import.rake b/lib/tasks/import.rake index c93be95e2e0..1e17a6a1073 100644 --- a/lib/tasks/import.rake +++ b/lib/tasks/import.rake @@ -4,8 +4,8 @@ require 'benchmark' require 'rainbow/ext/string' class GithubImport - def self.run!(*args) - new(*args).run! + def self.run!(...) + new(...).run! end def initialize(token, gitlab_username, project_path, extras) |