Commit 5632079c authored by Stan Hu's avatar Stan Hu

Properly clear the merge error upon rebase failure

If `merge_error` is ever set after a failure, it is never cleared, even
after a subsequent, successful rebase. We now clear this field whenever
a successful rebase occurs.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/56139
parent 3d2edaac
......@@ -1050,7 +1050,7 @@ class Repository
# To support the full deprecated behaviour, set the
# `rebase_commit_sha` for the merge_request here and return the value
merge_request.update(rebase_commit_sha: rebase_sha)
merge_request.update(rebase_commit_sha: rebase_sha, merge_error: nil)
rebase_sha
end
......@@ -1069,7 +1069,7 @@ class Repository
remote_repository: merge_request.target_project.repository.raw,
remote_branch: merge_request.target_branch
) do |commit_id|
merge_request.update!(rebase_commit_sha: commit_id)
merge_request.update!(rebase_commit_sha: commit_id, merge_error: nil)
end
end
end
......
---
title: Properly clear the merge error upon rebase failure
merge_request: 28319
author:
type: fixed
......@@ -38,6 +38,32 @@ describe MergeRequests::RebaseService do
end
end
shared_examples 'sequence of failure and success' do
it 'properly clears the error message' do
allow(repository).to receive(:gitaly_operation_client).and_raise('Something went wrong')
service.execute(merge_request)
expect(merge_request.reload.merge_error).to eq described_class::REBASE_ERROR
allow(repository).to receive(:gitaly_operation_client).and_call_original
service.execute(merge_request)
expect(merge_request.reload.merge_error).to eq nil
end
end
it_behaves_like 'sequence of failure and success'
context 'with deprecated step rebase feature' do
before do
allow(Feature).to receive(:disabled?).with(:two_step_rebase, anything).and_return(true)
end
it_behaves_like 'sequence of failure and success'
end
context 'when unexpected error occurs' do
before do
allow(repository).to receive(:gitaly_operation_client).and_raise('Something went wrong')
......
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