diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-11-30 09:06:14 +0000 |
---|---|---|
committer | Winnie Hellmann <winnie@gitlab.com> | 2017-12-14 09:11:17 +0000 |
commit | ec8d438d6536f08496d9dbbfe9608b0de17e56eb (patch) | |
tree | 40ea861ca523a088df17afac0fb90604ce52f923 | |
parent | ce513abb8f64a622392d9fc55f04d633f6b7ee65 (diff) | |
download | gitlab-ce-ec8d438d6536f08496d9dbbfe9608b0de17e56eb.tar.gz |
Merge branch 'protected-branches-names' into 'master'
Only load branch names for protected branch checks
See merge request gitlab-org/gitlab-ce!15629
(cherry picked from commit 1aaa6095a2d8890df73731a8af3d26158a198743)
a0527ab8 Only load branch names for protected branch checks
-rw-r--r-- | app/models/protected_branch.rb | 4 | ||||
-rw-r--r-- | app/models/protected_tag.rb | 4 | ||||
-rw-r--r-- | changelogs/unreleased/protected-branches-names.yml | 5 |
3 files changed, 11 insertions, 2 deletions
diff --git a/app/models/protected_branch.rb b/app/models/protected_branch.rb index 89bfc5f9a9c..d28fed11ca8 100644 --- a/app/models/protected_branch.rb +++ b/app/models/protected_branch.rb @@ -10,7 +10,9 @@ class ProtectedBranch < ActiveRecord::Base def self.protected?(project, ref_name) return true if project.empty_repo? && default_branch_protected? - self.matching(ref_name, protected_refs: project.protected_branches).present? + refs = project.protected_branches.select(:name) + + self.matching(ref_name, protected_refs: refs).present? end def self.default_branch_protected? diff --git a/app/models/protected_tag.rb b/app/models/protected_tag.rb index f38109c0e52..42a9bcf7723 100644 --- a/app/models/protected_tag.rb +++ b/app/models/protected_tag.rb @@ -5,6 +5,8 @@ class ProtectedTag < ActiveRecord::Base protected_ref_access_levels :create def self.protected?(project, ref_name) - self.matching(ref_name, protected_refs: project.protected_tags).present? + refs = project.protected_tags.select(:name) + + self.matching(ref_name, protected_refs: refs).present? end end diff --git a/changelogs/unreleased/protected-branches-names.yml b/changelogs/unreleased/protected-branches-names.yml new file mode 100644 index 00000000000..3c6767df571 --- /dev/null +++ b/changelogs/unreleased/protected-branches-names.yml @@ -0,0 +1,5 @@ +--- +title: Only load branch names for protected branch checks +merge_request: +author: +type: performance |