Commit c841c877 authored by Nick Thomas's avatar Nick Thomas

Merge branch 'sh-fix-rebase-error-clearing' into 'master'

Properly clear the merge error upon rebase failure

Closes #56139

See merge request gitlab-org/gitlab-ce!28319
parents fbdfc05b 5632079c
...@@ -1050,7 +1050,7 @@ class Repository ...@@ -1050,7 +1050,7 @@ class Repository
# To support the full deprecated behaviour, set the # To support the full deprecated behaviour, set the
# `rebase_commit_sha` for the merge_request here and return the value # `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 rebase_sha
end end
...@@ -1069,7 +1069,7 @@ class Repository ...@@ -1069,7 +1069,7 @@ class Repository
remote_repository: merge_request.target_project.repository.raw, remote_repository: merge_request.target_project.repository.raw,
remote_branch: merge_request.target_branch remote_branch: merge_request.target_branch
) do |commit_id| ) 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 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 ...@@ -38,6 +38,32 @@ describe MergeRequests::RebaseService do
end end
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 context 'when unexpected error occurs' do
before do before do
allow(repository).to receive(:gitaly_operation_client).and_raise('Something went wrong') 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