diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-06 21:08:48 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-06 21:08:48 +0000 |
commit | a89cb5cbdd832d4d9e80517973aceda6bc0a3856 (patch) | |
tree | 574475bd0901a2f8906d36a4728b8bbb95b41e1c /app/models | |
parent | 0d6fa033121a9bef708b8f2de186c4034c61d4a3 (diff) | |
download | gitlab-ce-a89cb5cbdd832d4d9e80517973aceda6bc0a3856.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/project.rb | 4 | ||||
-rw-r--r-- | app/models/protected_branch.rb | 7 |
2 files changed, 11 insertions, 0 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 78c3114ce9c..816d964519d 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -2304,6 +2304,10 @@ class Project < ApplicationRecord ci_config_path.blank? || ci_config_path == Gitlab::FileDetector::PATTERNS[:gitlab_ci] end + def limited_protected_branches(limit) + protected_branches.limit(limit) + end + private def closest_namespace_setting(name) diff --git a/app/models/protected_branch.rb b/app/models/protected_branch.rb index 735e2bdea81..94c3b83564f 100644 --- a/app/models/protected_branch.rb +++ b/app/models/protected_branch.rb @@ -2,6 +2,7 @@ class ProtectedBranch < ApplicationRecord include ProtectedRef + include Gitlab::SQL::Pattern scope :requiring_code_owner_approval, -> { where(code_owner_approval_required: true) } @@ -45,6 +46,12 @@ class ProtectedBranch < ApplicationRecord # NOOP # end + + def self.by_name(query) + return none if query.blank? + + where(fuzzy_arel_match(:name, query.downcase)) + end end ProtectedBranch.prepend_if_ee('EE::ProtectedBranch') |