diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-08 21:11:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-08 21:11:09 +0300 |
commit | da576e4a0b8e1adc3df559a163b01c962a565ef5 (patch) | |
tree | f563a8746fd54a2d638f6b421955220af24c8489 /app/models | |
parent | b5bdf6e5219b3b57107aee49ba7c103affb65dd9 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/deployment.rb | 3 | ||||
-rw-r--r-- | app/models/pages_domain.rb | 10 | ||||
-rw-r--r-- | app/models/project_setting.rb | 2 | ||||
-rw-r--r-- | app/models/serverless/domain_cluster.rb | 8 |
4 files changed, 14 insertions, 9 deletions
diff --git a/app/models/deployment.rb b/app/models/deployment.rb index 20841bc14cd..7116827f153 100644 --- a/app/models/deployment.rb +++ b/app/models/deployment.rb @@ -439,8 +439,9 @@ class Deployment < ApplicationRecord end # default tag limit is 100, 0 means no limit + # when refs_by_oid is passed an SHA, returns refs for that commit def tags(limit: 100) - project.repository.tag_names_contains(sha, limit: limit) + project.repository.refs_by_oid(oid: sha, limit: limit, ref_patterns: [Gitlab::Git::TAG_REF_PREFIX]) || [] end strong_memoize_attr :tags diff --git a/app/models/pages_domain.rb b/app/models/pages_domain.rb index 8b15db7badc..328c67a0711 100644 --- a/app/models/pages_domain.rb +++ b/app/models/pages_domain.rb @@ -10,8 +10,8 @@ class PagesDomain < ApplicationRecord SSL_RENEWAL_THRESHOLD = 30.days.freeze enum certificate_source: { user_provided: 0, gitlab_provided: 1 }, _prefix: :certificate - enum scope: { instance: 0, group: 1, project: 2 }, _prefix: :scope - enum usage: { pages: 0, serverless: 1 }, _prefix: :usage + enum scope: { instance: 0, group: 1, project: 2 }, _prefix: :scope, _default: :project + enum usage: { pages: 0, serverless: 1 }, _prefix: :usage, _default: :pages belongs_to :project has_many :acme_orders, class_name: "PagesDomainAcmeOrder" @@ -35,10 +35,8 @@ class PagesDomain < ApplicationRecord validate :validate_intermediates, if: ->(domain) { domain.certificate.present? && domain.certificate_changed? } validate :validate_custom_domain_count_per_project, on: :create - default_value_for(:auto_ssl_enabled, allows_nil: false) { ::Gitlab::LetsEncrypt.enabled? } - default_value_for :scope, allows_nil: false, value: :project - default_value_for :wildcard, allows_nil: false, value: false - default_value_for :usage, allows_nil: false, value: :pages + attribute :auto_ssl_enabled, default: -> { ::Gitlab::LetsEncrypt.enabled? } + attribute :wildcard, default: false attr_encrypted :key, mode: :per_attribute_iv_and_salt, diff --git a/app/models/project_setting.rb b/app/models/project_setting.rb index 4c3be49fddd..69b76b7efa9 100644 --- a/app/models/project_setting.rb +++ b/app/models/project_setting.rb @@ -26,7 +26,7 @@ class ProjectSetting < ApplicationRecord validate :validates_mr_default_target_self - default_value_for(:legacy_open_source_license_available) do + attribute :legacy_open_source_license_available, default: -> do Feature.enabled?(:legacy_open_source_license_available, type: :ops) end diff --git a/app/models/serverless/domain_cluster.rb b/app/models/serverless/domain_cluster.rb index 1effabf1c22..561bfc65b2b 100644 --- a/app/models/serverless/domain_cluster.rb +++ b/app/models/serverless/domain_cluster.rb @@ -19,7 +19,7 @@ module Serverless validates :uuid, presence: true, uniqueness: true, length: { is: ::Serverless::Domain::UUID_LENGTH }, format: { with: HEX_REGEXP, message: 'only allows hex characters' } - default_value_for(:uuid, allows_nil: false) { ::Serverless::Domain.generate_uuid } + after_initialize :set_uuid, if: :new_record? delegate :domain, to: :pages_domain delegate :cluster, to: :knative @@ -29,5 +29,11 @@ module Serverless .includes(:pages_domain, :knative) .find_by(uuid: uuid) end + + private + + def set_uuid + self.uuid = ::Serverless::Domain.generate_uuid + end end end |