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
|
|
|
|
|
|
|
|
# The version of the schema that first introduced this model/table.
|
|
|
|
MINIMUM_SCHEMA_VERSION = 20180403035759
|
|
|
|
|
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-09 13:42:32 +05:30
|
|
|
default_value_for :forward_deployment_enabled, true
|
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
def self.available?
|
|
|
|
@available ||=
|
|
|
|
ActiveRecord::Migrator.current_version >= MINIMUM_SCHEMA_VERSION
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.reset_column_information
|
|
|
|
@available = nil
|
|
|
|
super
|
|
|
|
end
|
2019-09-04 21:01:54 +05:30
|
|
|
|
2020-03-09 13:42:32 +05:30
|
|
|
def forward_deployment_enabled?
|
2020-04-08 14:13:33 +05:30
|
|
|
super && ::Feature.enabled?(:forward_deployment_enabled, project, default_enabled: true)
|
2020-03-09 13:42:32 +05:30
|
|
|
end
|
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
private
|
|
|
|
|
|
|
|
def set_default_git_depth
|
|
|
|
return unless Feature.enabled?(:ci_set_project_default_git_depth, default_enabled: true)
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
ProjectCiCdSetting.prepend_if_ee('EE::ProjectCiCdSetting')
|