Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-01-14 00:11:00 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-01-14 00:11:00 +0300
commitacba9e99b4f8bfeaaed143b72b07170a8506f893 (patch)
tree3f79c9c68e59c42c79dec7d4b353a3bbb3e118e0 /app/models/concerns/packages
parent716896e8cac8a516cd36efada8c8c5f383b63f62 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/concerns/packages')
-rw-r--r--app/models/concerns/packages/debian/architecture.rb25
-rw-r--r--app/models/concerns/packages/debian/distribution.rb5
2 files changed, 30 insertions, 0 deletions
diff --git a/app/models/concerns/packages/debian/architecture.rb b/app/models/concerns/packages/debian/architecture.rb
new file mode 100644
index 00000000000..4aa633e0357
--- /dev/null
+++ b/app/models/concerns/packages/debian/architecture.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+module Packages
+ module Debian
+ module Architecture
+ extend ActiveSupport::Concern
+
+ included do
+ belongs_to :distribution, class_name: "Packages::Debian::#{container_type.capitalize}Distribution", inverse_of: :architectures
+
+ validates :distribution,
+ presence: true
+
+ validates :name,
+ presence: true,
+ length: { maximum: 255 },
+ uniqueness: { scope: %i[distribution_id] },
+ format: { with: Gitlab::Regex.debian_architecture_regex }
+
+ scope :with_distribution, ->(distribution) { where(distribution: distribution) }
+ scope :with_name, ->(name) { where(name: name) }
+ end
+ end
+ end
+end
diff --git a/app/models/concerns/packages/debian/distribution.rb b/app/models/concerns/packages/debian/distribution.rb
index 2420f10f38a..948d4197285 100644
--- a/app/models/concerns/packages/debian/distribution.rb
+++ b/app/models/concerns/packages/debian/distribution.rb
@@ -18,6 +18,11 @@ module Packages
belongs_to container_type
belongs_to :creator, class_name: 'User'
+ has_many :architectures,
+ class_name: "Packages::Debian::#{container_type.capitalize}Architecture",
+ foreign_key: :distribution_id,
+ inverse_of: :distribution
+
validates :codename,
presence: true,
uniqueness: { scope: [container_foreign_key] },