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

metadatum.rb « rpm « packages « models « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 07361995a12e0ffda950c3361740dfdffdcb758f (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# frozen_string_literal: true

module Packages
  module Rpm
    class Metadatum < ApplicationRecord
      self.primary_key = :package_id

      belongs_to :package, -> { where(package_type: :rpm) }, inverse_of: :rpm_metadatum

      validates :package, presence: true

      validates :epoch,
                presence: true,
                numericality: { only_integer: true, greater_than_or_equal_to: 0 }

      validates :release,
                presence: true,
                length: { maximum: 128 }

      validates :summary,
                presence: true,
                length: { maximum: 1000 }

      validates :description,
                presence: true,
                length: { maximum: 5000 }

      validates :arch,
                presence: true,
                length: { maximum: 255 }

      validates :license,
                allow_nil: true,
                length: { maximum: 1000 }

      validates :url,
                allow_nil: true,
                length: { maximum: 1000 }

      validate :rpm_package_type

      private

      def rpm_package_type
        return if package&.rpm?

        errors.add(:base, _('Package type must be RPM'))
      end
    end
  end
end