2018-07-25 05:30:33 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-03-28 09:17:42 -04:00
|
|
|
class ProjectCiCdSetting < ApplicationRecord
|
2018-05-03 08:37:01 -04:00
|
|
|
belongs_to :project, inverse_of: :ci_cd_settings
|
2018-04-12 08:07:44 -04:00
|
|
|
|
|
|
|
# The version of the schema that first introduced this model/table.
|
|
|
|
MINIMUM_SCHEMA_VERSION = 20180403035759
|
|
|
|
|
2019-05-30 02:40:53 -04:00
|
|
|
DEFAULT_GIT_DEPTH = 50
|
|
|
|
|
2019-06-06 07:08:01 -04:00
|
|
|
before_create :set_default_git_depth
|
2019-05-30 02:40:53 -04:00
|
|
|
|
|
|
|
validates :default_git_depth,
|
|
|
|
numericality: {
|
|
|
|
only_integer: true,
|
|
|
|
greater_than_or_equal_to: 0,
|
|
|
|
less_than_or_equal_to: 1000
|
|
|
|
},
|
|
|
|
allow_nil: true
|
|
|
|
|
2018-04-12 08:07:44 -04:00
|
|
|
def self.available?
|
|
|
|
@available ||=
|
|
|
|
ActiveRecord::Migrator.current_version >= MINIMUM_SCHEMA_VERSION
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.reset_column_information
|
|
|
|
@available = nil
|
|
|
|
super
|
|
|
|
end
|
2019-05-30 02:40:53 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def set_default_git_depth
|
2019-06-10 13:40:19 -04:00
|
|
|
return unless Feature.enabled?(:ci_set_project_default_git_depth, default_enabled: true)
|
|
|
|
|
2019-06-06 08:39:46 -04:00
|
|
|
self.default_git_depth ||= DEFAULT_GIT_DEPTH
|
2019-05-30 02:40:53 -04:00
|
|
|
end
|
2018-04-12 08:07:44 -04:00
|
|
|
end
|