debian-mirror-gitlab/app/models/project_ci_cd_setting.rb

37 lines
959 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2019-07-07 11:18:12 +05:30
class ProjectCiCdSetting < ApplicationRecord
2018-10-15 14:42:47 +05:30
belongs_to :project, inverse_of: :ci_cd_settings
2019-09-04 21:01:54 +05:30
DEFAULT_GIT_DEPTH = 50
before_create :set_default_git_depth
validates :default_git_depth,
numericality: {
only_integer: true,
greater_than_or_equal_to: 0,
less_than_or_equal_to: 1000
},
allow_nil: true
2020-03-13 15:44:24 +05:30
default_value_for :forward_deployment_enabled, true
def forward_deployment_enabled?
2020-04-08 14:13:33 +05:30
super && ::Feature.enabled?(:forward_deployment_enabled, project, default_enabled: true)
2020-03-13 15:44:24 +05:30
end
2021-03-11 19:13:27 +05:30
def keep_latest_artifacts_available?
# The project level feature can only be enabled when the feature is enabled instance wide
Gitlab::CurrentSettings.current_application_settings.keep_latest_artifact? && keep_latest_artifact?
end
2019-09-04 21:01:54 +05:30
private
def set_default_git_depth
self.default_git_depth ||= DEFAULT_GIT_DEPTH
end
2018-10-15 14:42:47 +05:30
end
2019-12-04 20:38:33 +05:30
2021-06-08 01:23:25 +05:30
ProjectCiCdSetting.prepend_mod_with('ProjectCiCdSetting')