Commit b6a97278 authored by Stan Hu's avatar Stan Hu

Show pre-receive error message in merge request widget

When a merge fails due to a locked file, no feedback was given to the
user as to why it failed if the user used the Merge button.  However, if
the push attempt happened directly in the Web UI, the pre-receive
message would be displayed.

To be consistent and to make it clear why a merge failed, we now include
the pre-receive error message in the merge request widget.

Closes https://gitlab.com/gitlab-org/gitlab-ee/issues/10165
parent 5c9aa454
......@@ -76,8 +76,7 @@ module MergeRequests
def try_merge
repository.merge(current_user, source, merge_request, commit_message)
rescue Gitlab::Git::PreReceiveError => e
handle_merge_error(log_message: e.message)
raise_error('Something went wrong during merge pre-receive hook')
raise_error("Something went wrong during merge pre-receive hook: #{e.message}")
rescue => e
handle_merge_error(log_message: e.message)
raise_error('Something went wrong during merge')
......
---
title: Show pre-receive error message when merge fails
merge_request: 25708
author:
type: fixed
......@@ -244,7 +244,7 @@ describe MergeRequests::MergeService do
service.execute(merge_request)
expect(merge_request.merge_error).to include('Something went wrong during merge pre-receive hook')
expect(merge_request.merge_error).to include("Something went wrong during merge pre-receive hook: #{error_message}")
expect(Rails.logger).to have_received(:error).with(a_string_matching(error_message))
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