diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-19 17:16:28 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-19 17:16:28 +0300 |
commit | e4384360a16dd9a19d4d2d25d0ef1f2b862ed2a6 (patch) | |
tree | 2fcdfa7dcdb9db8f5208b2562f4b4e803d671243 /app/models/merge_request.rb | |
parent | ffda4e7bcac36987f936b4ba515995a6698698f0 (diff) |
Add latest changes from gitlab-org/gitlab@16-2-stable-eev16.2.0-rc42
Diffstat (limited to 'app/models/merge_request.rb')
-rw-r--r-- | app/models/merge_request.rb | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 116108ceaf9..2773569161d 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -421,7 +421,9 @@ class MergeRequest < ApplicationRecord scope :preload_latest_diff_commit, -> { preload(latest_merge_request_diff: { merge_request_diff_commits: [:commit_author, :committer] }) } scope :preload_milestoneish_associations, -> { preload_routables.preload(:assignees, :labels) } - scope :with_web_entity_associations, -> { preload(:author, target_project: [:project_feature, group: [:route, :parent], namespace: :route]) } + scope :with_web_entity_associations, -> do + preload(:author, :labels, target_project: [:project_feature, group: [:route, :parent], namespace: :route]) + end scope :with_auto_merge_enabled, -> do with_state(:opened).where(auto_merge_enabled: true) @@ -1199,10 +1201,17 @@ class MergeRequest < ApplicationRecord end alias_method :wip_title, :draft_title - def mergeable?(skip_ci_check: false, skip_discussions_check: false) + def skipped_mergeable_checks(options = {}) + { + skip_ci_check: options.fetch(:auto_merge_requested, false) + } + end + + def mergeable?(skip_ci_check: false, skip_discussions_check: false, skip_approved_check: false) return false unless mergeable_state?( skip_ci_check: skip_ci_check, - skip_discussions_check: skip_discussions_check + skip_discussions_check: skip_discussions_check, + skip_approved_check: skip_approved_check ) check_mergeability @@ -1223,11 +1232,12 @@ class MergeRequest < ApplicationRecord ] end - def mergeable_state?(skip_ci_check: false, skip_discussions_check: false) + def mergeable_state?(skip_ci_check: false, skip_discussions_check: false, skip_approved_check: false) additional_checks = execute_merge_checks( params: { skip_ci_check: skip_ci_check, - skip_discussions_check: skip_discussions_check + skip_discussions_check: skip_discussions_check, + skip_approved_check: skip_approved_check } ) additional_checks.success? @@ -1526,6 +1536,14 @@ class MergeRequest < ApplicationRecord "refs/#{Repository::REF_MERGE_REQUEST}/#{iid}/train" end + def schedule_cleanup_refs(only: :all) + if Feature.enabled?(:merge_request_cleanup_ref_worker_async, target_project) + MergeRequests::CleanupRefWorker.perform_async(id, only.to_s) + else + cleanup_refs(only: only) + end + end + def cleanup_refs(only: :all) target_refs = [] target_refs << ref_path if %i[all head].include?(only) |