diff options
author | Nick Thomas <nick@gitlab.com> | 2019-05-16 08:59:56 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-05-16 08:59:56 +0000 |
commit | c841c8771b8d69034c1ceb6e452746d193865cb0 (patch) | |
tree | 530feb483facad799e5744c950a3c3deb1300c94 | |
parent | fbdfc05b9e01f5511ec9723bbbb4a558962bb3ed (diff) | |
parent | 5632079c3684562aea890123182bd43648149b55 (diff) | |
download | gitlab-ce-c841c8771b8d69034c1ceb6e452746d193865cb0.tar.gz |
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
-rw-r--r-- | app/models/repository.rb | 4 | ||||
-rw-r--r-- | changelogs/unreleased/sh-fix-rebase-error-clearing.yml | 5 | ||||
-rw-r--r-- | spec/services/merge_requests/rebase_service_spec.rb | 26 |
3 files changed, 33 insertions, 2 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index 1c02e68f2f6..f540b00a849 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -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 diff --git a/changelogs/unreleased/sh-fix-rebase-error-clearing.yml b/changelogs/unreleased/sh-fix-rebase-error-clearing.yml new file mode 100644 index 00000000000..4f5f2779e7f --- /dev/null +++ b/changelogs/unreleased/sh-fix-rebase-error-clearing.yml @@ -0,0 +1,5 @@ +--- +title: Properly clear the merge error upon rebase failure +merge_request: 28319 +author: +type: fixed diff --git a/spec/services/merge_requests/rebase_service_spec.rb b/spec/services/merge_requests/rebase_service_spec.rb index a443e4588d9..0c4433453ac 100644 --- a/spec/services/merge_requests/rebase_service_spec.rb +++ b/spec/services/merge_requests/rebase_service_spec.rb @@ -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') |