2017-03-15 22:29:07 +00:00
|
|
|
class ProtectedTag < ActiveRecord::Base
|
|
|
|
include Gitlab::ShellAdapter
|
2017-04-03 14:17:24 +00:00
|
|
|
include ProtectedRef
|
2017-03-15 22:29:07 +00:00
|
|
|
|
2017-04-04 02:37:22 +00:00
|
|
|
has_many :create_access_levels, dependent: :destroy
|
2017-03-15 22:29:07 +00:00
|
|
|
|
2017-04-04 02:37:22 +00:00
|
|
|
validates :create_access_levels, length: { is: 1, message: "are restricted to a single instance per protected tag." }
|
2017-03-15 22:29:07 +00:00
|
|
|
|
2017-04-04 02:37:22 +00:00
|
|
|
accepts_nested_attributes_for :create_access_levels
|
2017-04-03 17:59:58 +00:00
|
|
|
|
|
|
|
def self.protected?(project, ref_name)
|
2017-04-03 18:47:08 +00:00
|
|
|
self.matching(ref_name, protected_refs: project.protected_tags).present?
|
2017-04-03 17:59:58 +00:00
|
|
|
end
|
2017-03-15 22:29:07 +00:00
|
|
|
end
|