Commit 22e8d36a authored by Douwe Maan's avatar Douwe Maan

Add MergeRequest#must_be_rebased? and use it in mergeable?

parent a7770f67
...@@ -179,11 +179,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -179,11 +179,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
return return
end end
if @project.ff_merge_must_be_possible? && !@merge_request.ff_merge_possible?
@status = :failed
return
end
@merge_request.update(merge_error: nil) @merge_request.update(merge_error: nil)
if params[:merge_when_build_succeeds].present? && @merge_request.ci_commit && @merge_request.ci_commit.active? if params[:merge_when_build_succeeds].present? && @merge_request.ci_commit && @merge_request.ci_commit.active?
......
...@@ -255,7 +255,7 @@ class MergeRequest < ActiveRecord::Base ...@@ -255,7 +255,7 @@ class MergeRequest < ActiveRecord::Base
end end
def mergeable? def mergeable?
open? && !work_in_progress? && can_be_merged? open? && !work_in_progress? && can_be_merged? && !must_be_rebased?
end end
def gitlab_merge_status def gitlab_merge_status
...@@ -567,6 +567,10 @@ class MergeRequest < ActiveRecord::Base ...@@ -567,6 +567,10 @@ class MergeRequest < ActiveRecord::Base
target_sha == source_sha_parent target_sha == source_sha_parent
end end
def must_be_rebased?
self.project.ff_merge_must_be_possible? && !ff_merge_possible?
end
def rebase_dir_path def rebase_dir_path
File.join(Gitlab.config.shared.path, 'tmp/rebase', source_project.id.to_s, id.to_s).to_s File.join(Gitlab.config.shared.path, 'tmp/rebase', source_project.id.to_s, id.to_s).to_s
end end
......
...@@ -9,8 +9,6 @@ module MergeRequests ...@@ -9,8 +9,6 @@ module MergeRequests
private private
def commit def commit
return false unless @merge_request.ff_merge_possible?
repository.ff_merge(current_user, merge_request.source_sha, merge_request.target_branch) repository.ff_merge(current_user, merge_request.source_sha, merge_request.target_branch)
end end
end end
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
= render 'projects/merge_requests/widget/open/merge_when_build_succeeds' = render 'projects/merge_requests/widget/open/merge_when_build_succeeds'
- elsif !@merge_request.can_be_merged_by?(current_user) - elsif !@merge_request.can_be_merged_by?(current_user)
= render 'projects/merge_requests/widget/open/not_allowed' = render 'projects/merge_requests/widget/open/not_allowed'
- elsif @project.ff_merge_must_be_possible? && !@merge_request.ff_merge_possible? - elsif @merge_request.must_be_rebased?
= render 'projects/merge_requests/widget/open/rebase' = render 'projects/merge_requests/widget/open/rebase'
- else - else
= render 'projects/merge_requests/widget/open/accept' = render 'projects/merge_requests/widget/open/accept'
......
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