Commit 305dc0e8 authored by Furkan Ayhan's avatar Furkan Ayhan

Fix unfinished merge by Merge Train process

This causes merge trains to be stuck.

The fix here is to handle Gitlab::Git::CommandError
for Branches::DeleteService
parent b74ee551
......@@ -26,7 +26,7 @@ module Branches
message: 'Failed to remove branch',
http_status: 400)
end
rescue Gitlab::Git::PreReceiveError => ex
rescue Gitlab::Git::PreReceiveError, Gitlab::Git::CommandError => ex
ServiceResponse.error(message: ex.message, http_status: 400)
end
......
---
title: Fix unfinished merge by Merge Train process
merge_request: 41106
author:
type: fixed
......@@ -37,6 +37,21 @@ RSpec.describe Branches::DeleteService do
end
it_behaves_like 'a deleted branch', 'feature'
context 'when Gitlab::Git::CommandError is raised' do
before do
allow(repository).to receive(:rm_branch) do
raise Gitlab::Git::CommandError.new('Could not update patch')
end
end
it 'handles and returns error' do
result = service.execute('feature')
expect(result.status).to eq(:error)
expect(result.message).to eq('Could not update patch')
end
end
end
context 'when user does not have access to push to repository' 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