diff options
author | Kerri Miller <kerrizor@kerrizor.com> | 2019-09-05 16:01:36 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-09-05 16:01:36 +0300 |
commit | 0e40b41e224f18076426578da08548ae22afdcd1 (patch) | |
tree | 3bf58eb8e415771f28270910a66672b4d9db87b9 /app/models/merge_request.rb | |
parent | 95ef27253909ba7ff30667af14f7ea2256c1ae8d (diff) |
Add structure to support EE feature of COAR
These are the structural changes for supporting the EE feature of moving
"code_owner_approval_required" state from existing on a project to being
on the protected branches individually, allowing for CODEOWNER
validation on push events.
Diffstat (limited to 'app/models/merge_request.rb')
-rw-r--r-- | app/models/merge_request.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 28e450f9b30..bc98ae0ce28 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -174,6 +174,7 @@ class MergeRequest < ApplicationRecord scope :from_project, ->(project) { where(source_project_id: project.id) } scope :merged, -> { with_state(:merged) } scope :closed_and_merged, -> { with_states(:closed, :merged) } + scope :open_and_closed, -> { with_states(:opened, :closed) } scope :from_source_branches, ->(branches) { where(source_branch: branches) } scope :by_commit_sha, ->(sha) do where('EXISTS (?)', MergeRequestDiff.select(1).where('merge_requests.latest_merge_request_diff_id = merge_request_diffs.id').by_commit_sha(sha)).reorder(nil) @@ -187,6 +188,11 @@ class MergeRequest < ApplicationRecord target_project: [:route, { namespace: :route }], source_project: [:route, { namespace: :route }]) } + scope :by_target_branch_wildcard, ->(wildcard_branch_name) do + where("target_branch LIKE ?", ApplicationRecord.sanitize_sql_like(wildcard_branch_name).tr('*', '%')) + end + scope :by_target_branch, ->(branch_name) { where(target_branch: branch_name) } + scope :preload_source_project, -> { preload(:source_project) } after_save :keep_around_commit |