gitlab-org--gitlab-foss/app/models/project_ci_cd_setting.rb
Krasimir Angelov b8704dce72 Comment why forks get default_git_depth of 0 instead nil
and simplify ProjectCiCdSetting#set_default_git_depth
2019-06-07 00:39:46 +12:00

36 lines
773 B
Ruby

# frozen_string_literal: true
class ProjectCiCdSetting < ApplicationRecord
belongs_to :project, inverse_of: :ci_cd_settings
# The version of the schema that first introduced this model/table.
MINIMUM_SCHEMA_VERSION = 20180403035759
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
def self.available?
@available ||=
ActiveRecord::Migrator.current_version >= MINIMUM_SCHEMA_VERSION
end
def self.reset_column_information
@available = nil
super
end
private
def set_default_git_depth
self.default_git_depth ||= DEFAULT_GIT_DEPTH
end
end