diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:55:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:55:51 +0300 |
commit | e8d2c2579383897a1dd7f9debd359abe8ae8373d (patch) | |
tree | c42be41678c2586d49a75cabce89322082698334 /app/models/packages | |
parent | fc845b37ec3a90aaa719975f607740c22ba6a113 (diff) |
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'app/models/packages')
-rw-r--r-- | app/models/packages/debian.rb | 4 | ||||
-rw-r--r-- | app/models/packages/event.rb | 6 | ||||
-rw-r--r-- | app/models/packages/go/module.rb | 2 | ||||
-rw-r--r-- | app/models/packages/helm.rb | 2 | ||||
-rw-r--r-- | app/models/packages/nuget.rb | 1 | ||||
-rw-r--r-- | app/models/packages/package.rb | 8 | ||||
-rw-r--r-- | app/models/packages/package_file.rb | 2 |
7 files changed, 14 insertions, 11 deletions
diff --git a/app/models/packages/debian.rb b/app/models/packages/debian.rb index f7f7f9f95e9..e20f1b8244a 100644 --- a/app/models/packages/debian.rb +++ b/app/models/packages/debian.rb @@ -2,6 +2,10 @@ module Packages module Debian + DISTRIBUTION_REGEX = %r{[a-z0-9][a-z0-9.-]*}i.freeze + COMPONENT_REGEX = DISTRIBUTION_REGEX.freeze + ARCHITECTURE_REGEX = %r{[a-z0-9][-a-z0-9]*}.freeze + def self.table_name_prefix 'packages_debian_' end diff --git a/app/models/packages/event.rb b/app/models/packages/event.rb index 98c9d5246db..a1eb7120117 100644 --- a/app/models/packages/event.rb +++ b/app/models/packages/event.rb @@ -3,7 +3,7 @@ class Packages::Event < ApplicationRecord belongs_to :package, optional: true - UNIQUE_EVENTS_ALLOWED = %i[push_package delete_package pull_package].freeze + UNIQUE_EVENTS_ALLOWED = %i[push_package delete_package pull_package pull_symbol_package push_symbol_package].freeze EVENT_SCOPES = ::Packages::Package.package_types.merge(container: 1000, tag: 1001).freeze EVENT_PREFIX = "i_package" @@ -21,7 +21,9 @@ class Packages::Event < ApplicationRecord delete_tag: 7, delete_tag_bulk: 8, list_tags: 9, - cli_metadata: 10 + cli_metadata: 10, + pull_symbol_package: 11, + push_symbol_package: 12 } enum originator_type: { user: 0, deploy_token: 1, guest: 2 } diff --git a/app/models/packages/go/module.rb b/app/models/packages/go/module.rb index 00d51c21881..a029437c82d 100644 --- a/app/models/packages/go/module.rb +++ b/app/models/packages/go/module.rb @@ -33,7 +33,7 @@ module Packages end def path_valid?(major) - m = /\/v(\d+)$/i.match(@name) + m = %r{/v(\d+)$}i.match(@name) case major when 0, 1 diff --git a/app/models/packages/helm.rb b/app/models/packages/helm.rb index e021b997bf5..b34ccf907dd 100644 --- a/app/models/packages/helm.rb +++ b/app/models/packages/helm.rb @@ -2,6 +2,8 @@ module Packages module Helm + TEMPORARY_PACKAGE_NAME = 'Helm.Temporary.Package' + def self.table_name_prefix 'packages_helm_' end diff --git a/app/models/packages/nuget.rb b/app/models/packages/nuget.rb index f152eedb8fc..6bedd488c8a 100644 --- a/app/models/packages/nuget.rb +++ b/app/models/packages/nuget.rb @@ -2,6 +2,7 @@ module Packages module Nuget TEMPORARY_PACKAGE_NAME = 'NuGet.Temporary.Package' + TEMPORARY_SYMBOL_PACKAGE_NAME = 'NuGet.Temporary.SymbolPackage' def self.table_name_prefix 'packages_nuget_' diff --git a/app/models/packages/package.rb b/app/models/packages/package.rb index b040c98ef09..d2e4f46898c 100644 --- a/app/models/packages/package.rb +++ b/app/models/packages/package.rb @@ -158,8 +158,6 @@ class Packages::Package < ApplicationRecord joins(:project).reorder(keyset_order) end - after_commit :update_composer_cache, on: :destroy, if: -> { composer? && Feature.disabled?(:disable_composer_callback) } - def self.only_maven_packages_with_path(path, use_cte: false) if use_cte # This is an optimization fence which assumes that looking up the Metadatum record by path (globally) @@ -295,12 +293,6 @@ class Packages::Package < ApplicationRecord private - def update_composer_cache - return unless composer? - - ::Packages::Composer::CacheUpdateWorker.perform_async(project_id, name, composer_metadatum.version_cache_sha) # rubocop:disable CodeReuse/Worker - end - def composer_tag_version? composer? && !Gitlab::Regex.composer_dev_version_regex.match(version.to_s) end diff --git a/app/models/packages/package_file.rb b/app/models/packages/package_file.rb index 3ef30c035e8..799242a639a 100644 --- a/app/models/packages/package_file.rb +++ b/app/models/packages/package_file.rb @@ -27,10 +27,12 @@ class Packages::PackageFile < ApplicationRecord validates :file_name, uniqueness: { scope: :package }, if: -> { package&.pypi? } scope :recent, -> { order(id: :desc) } + scope :limit_recent, ->(limit) { recent.limit(limit) } scope :for_package_ids, ->(ids) { where(package_id: ids) } scope :with_file_name, ->(file_name) { where(file_name: file_name) } scope :with_file_name_like, ->(file_name) { where(arel_table[:file_name].matches(file_name)) } scope :with_files_stored_locally, -> { where(file_store: ::Packages::PackageFileUploader::Store::LOCAL) } + scope :with_format, ->(format) { where(::Packages::PackageFile.arel_table[:file_name].matches("%.#{format}")) } scope :preload_conan_file_metadata, -> { preload(:conan_file_metadatum) } scope :preload_debian_file_metadata, -> { preload(:debian_file_metadatum) } scope :preload_helm_file_metadata, -> { preload(:helm_file_metadatum) } |