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

publication.rb « debian « packages « models « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 93f5aa11d8169bd00404bf21fa71bffa42e67137 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# frozen_string_literal: true

class Packages::Debian::Publication < ApplicationRecord
  belongs_to :package,
    -> { where(package_type: :debian).where.not(version: nil) },
    inverse_of: :debian_publication,
    class_name: 'Packages::Package'
  belongs_to :distribution,
    inverse_of: :publications,
    class_name: 'Packages::Debian::ProjectDistribution',
    foreign_key: :distribution_id

  validates :package, presence: true
  validate :valid_debian_package_type

  validates :distribution, presence: true

  private

  def valid_debian_package_type
    return errors.add(:package, _('type must be Debian')) unless package&.debian?
    return errors.add(:package, _('must be a Debian package')) unless package.debian_package?
  end
end