diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-07 12:05:55 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-07 12:05:55 +0300 |
commit | ab2382923e7a864a3fa27fdf8eeb9b21893b9147 (patch) | |
tree | 89a0d33672657f2c793b0966e1d82041f36c76c9 /app/services | |
parent | 3900b8a0062113e11e600e4226426e4163ac5e2c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/merge_requests/refresh_service.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/app/services/merge_requests/refresh_service.rb b/app/services/merge_requests/refresh_service.rb index edcfc3bf33f..b32499629ff 100644 --- a/app/services/merge_requests/refresh_service.rb +++ b/app/services/merge_requests/refresh_service.rb @@ -25,6 +25,7 @@ module MergeRequests outdate_suggestions refresh_pipelines_on_merge_requests abort_auto_merges + abort_ff_merge_requests_with_when_pipeline_succeeds mark_pending_todos_done cache_merge_requests_closing_issues @@ -148,6 +149,31 @@ module MergeRequests end end + def abort_ff_merge_requests_with_when_pipeline_succeeds + return unless @project.ff_merge_must_be_possible? + + requests_with_auto_merge_enabled_to(@push.branch_name).each do |merge_request| + next unless merge_request.should_be_rebased? + + abort_auto_merge_with_todo(merge_request, 'target branch was updated') + end + end + + def abort_auto_merge_with_todo(merge_request, reason) + response = abort_auto_merge(merge_request, reason) + response = ServiceResponse.new(response) + return unless response.success? + + todo_service.merge_request_became_unmergeable(merge_request) + end + + def requests_with_auto_merge_enabled_to(target_branch) + @project + .merge_requests + .by_target_branch(target_branch) + .with_open_merge_when_pipeline_succeeds + end + def mark_pending_todos_done merge_requests_for_source_branch.each do |merge_request| todo_service.merge_request_push(merge_request, @current_user) |