Commit 2aa03bf0 authored by Kerri Miller's avatar Kerri Miller Committed by Jan Provaznik

Remove :merge_orchestration_service FF added in 12.10

parent ace3a8f4
......@@ -1639,18 +1639,6 @@ class MergeRequest < ApplicationRecord
!has_commits?
end
def mergeable_with_quick_action?(current_user, autocomplete_precheck: false, last_diff_sha: nil)
return false unless can_be_merged_by?(current_user)
return true if autocomplete_precheck
return false unless mergeable?(skip_ci_check: true)
return false if actual_head_pipeline && !(actual_head_pipeline.success? || actual_head_pipeline.active?)
return false if last_diff_sha != diff_head_sha
true
end
def pipeline_coverage_delta
if base_pipeline&.coverage && head_pipeline&.coverage
'%.2f' % (head_pipeline.coverage.to_f - base_pipeline.coverage.to_f)
......
......@@ -132,21 +132,9 @@ module MergeRequests
def merge_from_quick_action(merge_request)
last_diff_sha = params.delete(:merge)
if Feature.enabled?(:merge_orchestration_service, merge_request.project, default_enabled: true)
MergeRequests::MergeOrchestrationService
.new(project, current_user, { sha: last_diff_sha })
.execute(merge_request)
else
return unless merge_request.mergeable_with_quick_action?(current_user, last_diff_sha: last_diff_sha)
merge_request.update(merge_error: nil)
if merge_request.head_pipeline_active?
AutoMergeService.new(project, current_user, { sha: last_diff_sha }).execute(merge_request, AutoMergeService::STRATEGY_MERGE_WHEN_PIPELINE_SUCCEEDS)
else
merge_request.merge_async(current_user.id, { sha: last_diff_sha })
end
end
MergeRequests::MergeOrchestrationService
.new(project, current_user, { sha: last_diff_sha })
.execute(merge_request)
end
override :quick_action_options
......
---
name: merge_orchestration_service
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/28532
rollout_issue_url:
milestone: '12.10'
type: development
group: group::continuous integration
default_enabled: true
......@@ -1003,47 +1003,6 @@ RSpec.describe MergeRequest do
end
end
describe '#mergeable_with_quick_action?' do
def create_pipeline(status)
pipeline = create(:ci_pipeline,
project: project,
ref: merge_request.source_branch,
sha: merge_request.diff_head_sha,
status: status,
head_pipeline_of: merge_request)
pipeline
end
let(:project) { create(:project, :public, :repository, only_allow_merge_if_pipeline_succeeds: true) }
let(:developer) { create(:user) }
let(:user) { create(:user) }
let(:merge_request) { create(:merge_request, source_project: project) }
let(:mr_sha) { merge_request.diff_head_sha }
before do
project.add_developer(developer)
end
context 'when autocomplete_precheck is set to false' do
context 'with approvals' do
before do
merge_request.target_project.update(approvals_before_merge: 1)
end
it 'is not mergeable when not approved' do
expect(merge_request.mergeable_with_quick_action?(developer, last_diff_sha: mr_sha)).to be_falsey
end
it 'is mergeable when approved' do
merge_request.approvals.create(user: user)
expect(merge_request.mergeable_with_quick_action?(developer, last_diff_sha: mr_sha)).to be_truthy
end
end
end
end
describe '#approver_group_ids=' do
it 'create approver_groups' do
group = create :group
......
......@@ -9,48 +9,30 @@ module Gitlab
included do
# MergeRequest only quick actions definitions
desc do
if Feature.enabled?(:merge_orchestration_service, quick_action_target.project, default_enabled: true)
if preferred_strategy = preferred_auto_merge_strategy(quick_action_target)
_("Merge automatically (%{strategy})") % { strategy: preferred_strategy.humanize }
else
_("Merge immediately")
end
if preferred_strategy = preferred_auto_merge_strategy(quick_action_target)
_("Merge automatically (%{strategy})") % { strategy: preferred_strategy.humanize }
else
_('Merge (when the pipeline succeeds)')
_("Merge immediately")
end
end
explanation do
if Feature.enabled?(:merge_orchestration_service, quick_action_target.project, default_enabled: true)
if preferred_strategy = preferred_auto_merge_strategy(quick_action_target)
_("Schedules to merge this merge request (%{strategy}).") % { strategy: preferred_strategy.humanize }
else
_('Merges this merge request immediately.')
end
if preferred_strategy = preferred_auto_merge_strategy(quick_action_target)
_("Schedules to merge this merge request (%{strategy}).") % { strategy: preferred_strategy.humanize }
else
_('Merges this merge request when the pipeline succeeds.')
_('Merges this merge request immediately.')
end
end
execution_message do
if Feature.enabled?(:merge_orchestration_service, quick_action_target.project, default_enabled: true)
if preferred_strategy = preferred_auto_merge_strategy(quick_action_target)
_("Scheduled to merge this merge request (%{strategy}).") % { strategy: preferred_strategy.humanize }
else
_('Merged this merge request.')
end
if preferred_strategy = preferred_auto_merge_strategy(quick_action_target)
_("Scheduled to merge this merge request (%{strategy}).") % { strategy: preferred_strategy.humanize }
else
_('Scheduled to merge this merge request when the pipeline succeeds.')
_('Merged this merge request.')
end
end
types MergeRequest
condition do
if Feature.enabled?(:merge_orchestration_service, quick_action_target.project, default_enabled: true)
quick_action_target.persisted? &&
merge_orchestration_service.can_merge?(quick_action_target)
else
last_diff_sha = params && params[:merge_request_diff_head_sha]
quick_action_target.persisted? &&
quick_action_target.mergeable_with_quick_action?(current_user, autocomplete_precheck: !last_diff_sha, last_diff_sha: last_diff_sha)
end
quick_action_target.persisted? &&
merge_orchestration_service.can_merge?(quick_action_target)
end
command :merge do
@updates[:merge] = params[:merge_request_diff_head_sha]
......
......@@ -17263,9 +17263,6 @@ msgstr ""
msgid "Merge"
msgstr ""
msgid "Merge (when the pipeline succeeds)"
msgstr ""
msgid "Merge Conflicts"
msgstr ""
......@@ -17506,9 +17503,6 @@ msgstr ""
msgid "Merges this merge request immediately."
msgstr ""
msgid "Merges this merge request when the pipeline succeeds."
msgstr ""
msgid "Merging immediately isn't recommended as it may negatively impact the existing merge train. Read the %{docsLinkStart}documentation%{docsLinkEnd} for more information."
msgstr ""
......@@ -24211,9 +24205,6 @@ msgstr ""
msgid "Scheduled to merge this merge request (%{strategy})."
msgstr ""
msgid "Scheduled to merge this merge request when the pipeline succeeds."
msgstr ""
msgid "Schedules"
msgstr ""
......
......@@ -3555,112 +3555,6 @@ RSpec.describe MergeRequest, factory_default: :keep do
end
end
describe '#mergeable_with_quick_action?' do
def create_pipeline(status)
pipeline = create(:ci_pipeline,
project: project,
ref: merge_request.source_branch,
sha: merge_request.diff_head_sha,
status: status,
head_pipeline_of: merge_request)
pipeline
end
let_it_be(:project) { create(:project, :public, :repository, only_allow_merge_if_pipeline_succeeds: true) }
let(:developer) { create(:user) }
let(:user) { create(:user) }
let(:merge_request) { create(:merge_request, source_project: project) }
let(:mr_sha) { merge_request.diff_head_sha }
before do
project.add_developer(developer)
end
context 'when autocomplete_precheck is set to true' do
it 'is mergeable by developer' do
expect(merge_request.mergeable_with_quick_action?(developer, autocomplete_precheck: true)).to be_truthy
end
it 'is not mergeable by normal user' do
expect(merge_request.mergeable_with_quick_action?(user, autocomplete_precheck: true)).to be_falsey
end
end
context 'when autocomplete_precheck is set to false' do
it 'is mergeable by developer' do
expect(merge_request.mergeable_with_quick_action?(developer, last_diff_sha: mr_sha)).to be_truthy
end
it 'is not mergeable by normal user' do
expect(merge_request.mergeable_with_quick_action?(user, last_diff_sha: mr_sha)).to be_falsey
end
context 'closed MR' do
before do
merge_request.update_attribute(:state_id, described_class.available_states[:closed])
end
it 'is not mergeable' do
expect(merge_request.mergeable_with_quick_action?(developer, last_diff_sha: mr_sha)).to be_falsey
end
end
context 'MR with WIP' do
before do
merge_request.update_attribute(:title, 'WIP: some MR')
end
it 'is not mergeable' do
expect(merge_request.mergeable_with_quick_action?(developer, last_diff_sha: mr_sha)).to be_falsey
end
end
context 'sha differs from the MR diff_head_sha' do
it 'is not mergeable' do
expect(merge_request.mergeable_with_quick_action?(developer, last_diff_sha: 'some other sha')).to be_falsey
end
end
context 'sha is not provided' do
it 'is not mergeable' do
expect(merge_request.mergeable_with_quick_action?(developer)).to be_falsey
end
end
context 'with pipeline ok' do
before do
create_pipeline(:success)
end
it 'is mergeable' do
expect(merge_request.mergeable_with_quick_action?(developer, last_diff_sha: mr_sha)).to be_truthy
end
end
context 'with failing pipeline' do
before do
create_pipeline(:failed)
end
it 'is not mergeable' do
expect(merge_request.mergeable_with_quick_action?(developer, last_diff_sha: mr_sha)).to be_falsey
end
end
context 'with running pipeline' do
before do
create_pipeline(:running)
end
it 'is mergeable' do
expect(merge_request.mergeable_with_quick_action?(developer, last_diff_sha: mr_sha)).to be_truthy
end
end
end
end
describe '#pipeline_coverage_delta' do
let!(:merge_request) { create(:merge_request) }
......
......@@ -431,14 +431,6 @@ RSpec.describe MergeRequests::UpdateService, :mailer do
describe 'merge' do
it_behaves_like 'correct merge behavior'
context 'when merge_orchestration_service feature flag is disabled' do
before do
stub_feature_flags(merge_orchestration_service: false)
end
it_behaves_like 'correct merge behavior'
end
end
context 'todos' do
......
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