Commit d3306a77 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'rm-25228-pre-receive-error' into 'master'

Propagate error on FF pre-receive failure

See merge request gitlab-org/gitlab!35633
parents eac1bfe8 7f039c3f
......@@ -27,6 +27,7 @@ module MergeRequests
success
end
end
log_info("Merge process finished on JID #{merge_jid} with state #{state}")
rescue MergeError => e
handle_merge_error(log_message: e.message, save_message_on_model: true)
......
---
title: Propagate error on FF pre-receive failure
merge_request: 35633
author:
type: fixed
......@@ -178,6 +178,10 @@ module Gitlab
timeout: GitalyClient.long_timeout
)
if response.pre_receive_error.present?
raise Gitlab::Git::PreReceiveError.new("GL-HOOK-ERR: pre-receive hook failed.")
end
Gitlab::Git::OperationService::BranchUpdate.from_gitaly(response.branch_update)
rescue GRPC::FailedPrecondition => e
raise Gitlab::Git::CommitError, e
......
......@@ -191,6 +191,20 @@ RSpec.describe Gitlab::GitalyClient::OperationService do
it { expect(subject).to be_nil }
end
context "when the pre-receive hook fails" do
let(:response) do
Gitaly::UserFFBranchResponse.new(
branch_update: nil,
pre_receive_error: "pre-receive hook error message\n"
)
end
it "raises the error" do
# the PreReceiveError class strips the GL-HOOK-ERR prefix from this error
expect { subject }.to raise_error(Gitlab::Git::PreReceiveError, "pre-receive hook failed.")
end
end
end
shared_examples 'cherry pick and revert errors' do
......
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