Commit ac425c15 authored by Sean McGivern's avatar Sean McGivern

Merge branch '4020-rebase-message' into 'master'

Resolve 'Rebase fails with "something went wrong" and huge ugly conflict error.'

Closes #41820

See merge request gitlab-org/gitlab-ce!16326
parents 06713cb7 a560f785
module MergeRequests
class RebaseService < MergeRequests::WorkingCopyBaseService
REBASE_ERROR = 'Rebase failed. Please rebase locally'.freeze
def execute(merge_request)
@merge_request = merge_request
if rebase
success
else
error('Failed to rebase. Should be done manually')
error(REBASE_ERROR)
end
end
......@@ -22,8 +24,8 @@ module MergeRequests
true
rescue => e
log_error('Failed to rebase branch:')
log_error(e.message, save_message_on_model: true)
log_error(REBASE_ERROR, save_message_on_model: true)
log_error(e.message)
false
end
end
......
---
title: Display user friendly error message if rebase fails.
merge_request:
author:
type: fixed
......@@ -32,7 +32,7 @@ describe MergeRequests::RebaseService do
it 'returns an error' do
expect(service.execute(merge_request)).to match(status: :error,
message: 'Failed to rebase. Should be done manually')
message: described_class::REBASE_ERROR)
end
end
......@@ -41,15 +41,15 @@ describe MergeRequests::RebaseService do
allow(repository).to receive(:run_git!).and_raise('Something went wrong')
end
it 'saves the error message' do
it 'saves a generic error message' do
subject.execute(merge_request)
expect(merge_request.reload.merge_error).to eq 'Something went wrong'
expect(merge_request.reload.merge_error).to eq described_class::REBASE_ERROR
end
it 'returns an error' do
expect(service.execute(merge_request)).to match(status: :error,
message: 'Failed to rebase. Should be done manually')
message: described_class::REBASE_ERROR)
end
end
......@@ -58,15 +58,15 @@ describe MergeRequests::RebaseService do
allow(repository).to receive(:run_git!).and_raise(Gitlab::Git::Repository::GitError, 'Something went wrong')
end
it 'saves the error message' do
it 'saves a generic error message' do
subject.execute(merge_request)
expect(merge_request.reload.merge_error).to eq 'Something went wrong'
expect(merge_request.reload.merge_error).to eq described_class::REBASE_ERROR
end
it 'returns an error' do
expect(service.execute(merge_request)).to match(status: :error,
message: 'Failed to rebase. Should be done manually')
message: described_class::REBASE_ERROR)
end
end
......
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