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