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:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-11-08 13:33:01 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-11-08 13:33:01 +0300
commit6edb7e9bb152d919c215f35bd6cb7d52fd3d99be (patch)
treef12ef4b7953932f9b2b9c28313277bf636115bc8 /app/models/protected_branch.rb
parent305ea394efd2d5afe16234406dede486d9ca37af (diff)
Add latest changes from gitlab-org/gitlab@14-4-stable-ee
Diffstat (limited to 'app/models/protected_branch.rb')
-rw-r--r--app/models/protected_branch.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/app/models/protected_branch.rb b/app/models/protected_branch.rb
index b4e2d17c3e5..96002c8668a 100644
--- a/app/models/protected_branch.rb
+++ b/app/models/protected_branch.rb
@@ -27,12 +27,17 @@ class ProtectedBranch < ApplicationRecord
# Check if branch name is marked as protected in the system
def self.protected?(project, ref_name)
return true if project.empty_repo? && project.default_branch_protected?
+ return false if ref_name.blank?
- Rails.cache.fetch("protected_ref-#{ref_name}-#{project.cache_key}") do
+ Rails.cache.fetch(protected_ref_cache_key(project, ref_name)) do
self.matching(ref_name, protected_refs: protected_refs(project)).present?
end
end
+ def self.protected_ref_cache_key(project, ref_name)
+ "protected_ref-#{project.cache_key}-#{Digest::SHA1.hexdigest(ref_name)}"
+ end
+
def self.allow_force_push?(project, ref_name)
project.protected_branches.allowing_force_push.matching(ref_name).any?
end