diff options
Diffstat (limited to 'app/workers/merge_requests/mergeability_check_batch_worker.rb')
-rw-r--r-- | app/workers/merge_requests/mergeability_check_batch_worker.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/app/workers/merge_requests/mergeability_check_batch_worker.rb b/app/workers/merge_requests/mergeability_check_batch_worker.rb index cbe34ac3790..f48e9c234ab 100644 --- a/app/workers/merge_requests/mergeability_check_batch_worker.rb +++ b/app/workers/merge_requests/mergeability_check_batch_worker.rb @@ -15,10 +15,16 @@ module MergeRequests @logger ||= Sidekiq.logger end - def perform(merge_request_ids) + def perform(merge_request_ids, user_id) merge_requests = MergeRequest.id_in(merge_request_ids) + user = User.find_by_id(user_id) merge_requests.each do |merge_request| + # Skip projects that user doesn't have update_merge_request access + next if merge_status_recheck_not_allowed?(merge_request, user) + + merge_request.mark_as_checking + result = merge_request.check_mergeability next unless result&.error? @@ -30,5 +36,12 @@ module MergeRequests ) end end + + private + + def merge_status_recheck_not_allowed?(merge_request, user) + ::Feature.enabled?(:restrict_merge_status_recheck, merge_request.project) && + !Ability.allowed?(user, :update_merge_request, merge_request.project) + end end end |