2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
class ProtectedTag < ActiveRecord::Base
|
|
|
|
include Gitlab::ShellAdapter
|
|
|
|
include ProtectedRef
|
|
|
|
|
2018-11-20 20:47:30 +05:30
|
|
|
validates :name, uniqueness: { scope: :project_id }
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
protected_ref_access_levels :create
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
def self.protected?(project, ref_name)
|
2018-03-17 18:26:18 +05:30
|
|
|
refs = project.protected_tags.select(:name)
|
|
|
|
|
|
|
|
self.matching(ref_name, protected_refs: refs).present?
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|