Commit 04a50bd9 authored by James Edwards-Jones's avatar James Edwards-Jones

Removed protected_tags_array

This memorized array appears to originally come from https://gitlab.com/gitlab-org/gitlab-ee/commit/19c2c90ccac86a21eb4266b9a5972162f917f692 which has a commit message of ‘fix warnings’. Without any comments on the original pull request I think we can safely get rid of it unless warnings re-appear.
parent 4f71c29c
...@@ -883,16 +883,6 @@ class Project < ActiveRecord::Base ...@@ -883,16 +883,6 @@ class Project < ActiveRecord::Base
"#{url}.git" "#{url}.git"
end end
#TODO: Check with if this is still needed, maybe because of `.select {` in ProtectedRefsMatcher
#Either with tests or by asking Tim
def protected_tags_array
@protected_tags_array ||= self.protected_tags.to_a
end
def protected_branches_array
@protected_branches_array ||= self.protected_branches.to_a
end
def user_can_push_to_empty_repo?(user) def user_can_push_to_empty_repo?(user)
!ProtectedBranch.default_branch_protected? || team.max_member_access(user.id) > Gitlab::Access::DEVELOPER !ProtectedBranch.default_branch_protected? || team.max_member_access(user.id) > Gitlab::Access::DEVELOPER
end end
......
...@@ -15,8 +15,7 @@ class ProtectedBranch < ActiveRecord::Base ...@@ -15,8 +15,7 @@ class ProtectedBranch < ActiveRecord::Base
def self.protected?(project, ref_name) def self.protected?(project, ref_name)
return true if project.empty_repo? && default_branch_protected? return true if project.empty_repo? && default_branch_protected?
protected_refs = project.protected_branches_array self.matching(ref_name, protected_refs: project.protected_branches).present?
self.matching(ref_name, protected_refs: protected_refs).present?
end end
def self.default_branch_protected? def self.default_branch_protected?
......
...@@ -9,7 +9,6 @@ class ProtectedTag < ActiveRecord::Base ...@@ -9,7 +9,6 @@ class ProtectedTag < ActiveRecord::Base
accepts_nested_attributes_for :push_access_levels accepts_nested_attributes_for :push_access_levels
def self.protected?(project, ref_name) def self.protected?(project, ref_name)
protected_refs = project.protected_tags_array self.matching(ref_name, protected_refs: project.protected_tags).present?
self.matching(ref_name, protected_refs: protected_refs).present?
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment