Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Edwards-Jones <jedwardsjones@gitlab.com>2017-03-16 01:29:07 +0300
committerJames Edwards-Jones <jedwardsjones@gitlab.com>2017-03-31 21:37:01 +0300
commit91ed8ed687ee9edbda0098475e66ad41f886d7a5 (patch)
tree7a446fa1048484d2ccb25a37e7ce650884b7d76f /app/models/protected_tag.rb
parent1a416a42f1c1b876ecd96687e41696bc915cc2c2 (diff)
Protected tags copy/paste from protected branches
Should provide basic CRUD backend for frontend to work from. Doesn’t include frontend, API, or the internal API used from gitlab-shell
Diffstat (limited to 'app/models/protected_tag.rb')
-rw-r--r--app/models/protected_tag.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/app/models/protected_tag.rb b/app/models/protected_tag.rb
new file mode 100644
index 00000000000..d307549aa49
--- /dev/null
+++ b/app/models/protected_tag.rb
@@ -0,0 +1,39 @@
+class ProtectedTag < ActiveRecord::Base
+ include Gitlab::ShellAdapter
+
+ belongs_to :project
+ validates :name, presence: true
+ validates :project, presence: true
+
+ has_many :push_access_levels, dependent: :destroy
+
+ validates :push_access_levels, length: { is: 1, message: "are restricted to a single instance per protected tag." }
+
+ accepts_nested_attributes_for :push_access_levels
+
+ def commit
+ project.commit(self.name)
+ end
+
+ def self.matching(tag_name, protected_tags: nil)
+ ProtectedRefMatcher.matching(ProtectedTag, tag_name, protected_refs: protected_tags)
+ end
+
+ def matching(branches)
+ ref_matcher.matching(branches)
+ end
+
+ def matches?(tag_name)
+ ref_matcher.matches?(tag_name)
+ end
+
+ def wildcard?
+ ref_matcher.wildcard?
+ end
+
+ private
+
+ def ref_matcher
+ @ref_matcher ||= ProtectedRefMatcher.new(self)
+ end
+end