Commit 6c22c01a authored by Kerri Miller's avatar Kerri Miller

Merge branch 'pb-handle-git-errors-cleanup-refs' into 'master'

Handle git errors when cleaning up MR refs

See merge request gitlab-org/gitlab!50250
parents a50560e3 5f1c3ce8
......@@ -36,6 +36,8 @@ module MergeRequests
return error('Failed to update schedule.') unless update_schedule
success
rescue Gitlab::Git::Repository::GitError, Gitlab::Git::CommandError => e
error(e.message)
end
private
......
---
title: Handle git errors when cleaning up MR refs
merge_request: 50250
author:
type: fixed
......@@ -91,6 +91,26 @@ RSpec.describe MergeRequests::CleanupRefsService do
it_behaves_like 'service that does not clean up merge request refs'
end
context 'when a git error is raised' do
context 'Gitlab::Git::Repository::GitError' do
before do
allow(merge_request.project.repository).to receive(:delete_refs).and_raise(Gitlab::Git::Repository::GitError)
end
it_behaves_like 'service that does not clean up merge request refs'
end
context 'Gitlab::Git::CommandError' do
before do
allow_next_instance_of(Gitlab::Git::KeepAround) do |keep_around|
expect(keep_around).to receive(:kept_around?).and_raise(Gitlab::Git::CommandError)
end
end
it_behaves_like 'service that does not clean up merge request refs'
end
end
context 'when cleanup schedule fails to update' do
before do
allow(merge_request.cleanup_schedule).to receive(:update).and_return(false)
......
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