Commit 92f5a5fd authored by Douwe Maan's avatar Douwe Maan

Merge branch '3142-fix-merge-request-approvals-validation-error' into 'master'

fix the approvals_before_merge project fallback

Closes #3142

See merge request gitlab-org/gitlab-ee!2932
parents 82d65226 f2f8de61
---
title: Fix a merge request validation error on forked projects.
merge_request: 2932
author:
type: fixed
...@@ -36,8 +36,15 @@ module EE ...@@ -36,8 +36,15 @@ module EE
def clamp_approvals_before_merge(mr_params) def clamp_approvals_before_merge(mr_params)
return mr_params unless mr_params[:approvals_before_merge] return mr_params unless mr_params[:approvals_before_merge]
target_project = @project.forked_from_project if @project.id.to_s != mr_params[:target_project_id] # Target the MR target project in priority, else it depends whether the project
target_project ||= @project # is forked.
target_project = if @merge_request
@merge_request.target_project
elsif @project.forked? && @project.id.to_s != mr_params[:target_project_id]
@project.forked_from_project
else
@project
end
if mr_params[:approvals_before_merge].to_i <= target_project.approvals_before_merge if mr_params[:approvals_before_merge].to_i <= target_project.approvals_before_merge
mr_params[:approvals_before_merge] = nil mr_params[:approvals_before_merge] = nil
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment