Class: Packages::Nuget::CheckDuplicatesService

Inherits:
BaseService
  • Object
show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/services/packages/nuget/check_duplicates_service.rb

Constant Summary collapse

ExtractionError =
Class.new(StandardError)

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

This class inherits a constructor from BaseService

Instance Method Details

#executeObject



10
11
12
13
14
15
16
17
18
19
# File 'app/services/packages/nuget/check_duplicates_service.rb', line 10

def execute
  return ServiceResponse.success if package_settings_allow_duplicates? || !target_package_is_duplicate?

  ServiceResponse.error(
    message: 'A package with the same name and version already exists',
    reason: :conflict
  )
rescue ExtractionError => e
  ServiceResponse.error(message: e.message, reason: :bad_request)
end