mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-22 11:06:10 +10:00
Allow people to remove source branch of fork project in MR
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
@@ -216,7 +216,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
|
||||
end
|
||||
|
||||
def allowed_to_merge?
|
||||
allowed_to_push_code?(project)
|
||||
allowed_to_push_code?(project, @merge_request.target_branch)
|
||||
end
|
||||
|
||||
def invalid_mr
|
||||
@@ -225,17 +225,17 @@ class Projects::MergeRequestsController < Projects::ApplicationController
|
||||
end
|
||||
|
||||
def allowed_to_remove_source_branch?
|
||||
allowed_to_push_code?(@merge_request.source_project) &&
|
||||
allowed_to_push_code?(@merge_request.source_project, @merge_request.source_branch) &&
|
||||
!@merge_request.disallow_source_branch_removal?
|
||||
end
|
||||
|
||||
def allowed_to_push_code?(project)
|
||||
action = if project.protected_branch?(@merge_request.target_branch)
|
||||
def allowed_to_push_code?(project, branch)
|
||||
action = if project.protected_branch?(branch)
|
||||
:push_code_to_protected_branches
|
||||
else
|
||||
:push_code
|
||||
end
|
||||
|
||||
can?(current_user, action, @project)
|
||||
can?(current_user, action, project)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -210,7 +210,7 @@ class MergeRequest < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def disallow_source_branch_removal?
|
||||
(source_project.root_ref? source_branch) || for_fork?
|
||||
source_project.root_ref?(source_branch) || source_project.protected_branches.include?(source_branch)
|
||||
end
|
||||
|
||||
def project
|
||||
|
||||
Reference in New Issue
Block a user