Commit 573bc5f6 authored by Shinya Maeda's avatar Shinya Maeda

Merge branch '217908-handle-git-errors' into 'master'

Fix unfinished merge by Merge Train process

See merge request gitlab-org/gitlab!41106
parents 53ab8788 305dc0e8
......@@ -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