From 100c687cbc49c592afc1c08bfda9e21d97a115b1 Mon Sep 17 00:00:00 2001 From: Sergey Sinev Date: Wed, 25 Apr 2018 20:37:52 +0300 Subject: [PATCH] Fix error when deleting an empty list of refs Closes #45743 --- ...don-gitlab-ce-fix-45743-master-fix-gitaly-delete-refs.yml | 5 +++++ lib/gitlab/git/repository.rb | 2 +- spec/lib/gitlab/git/repository_spec.rb | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/xeodon-gitlab-ce-fix-45743-master-fix-gitaly-delete-refs.yml diff --git a/changelogs/unreleased/xeodon-gitlab-ce-fix-45743-master-fix-gitaly-delete-refs.yml b/changelogs/unreleased/xeodon-gitlab-ce-fix-45743-master-fix-gitaly-delete-refs.yml new file mode 100644 index 00000000000..94da4d74300 --- /dev/null +++ b/changelogs/unreleased/xeodon-gitlab-ce-fix-45743-master-fix-gitaly-delete-refs.yml @@ -0,0 +1,5 @@ +--- +title: Fix error when deleting an empty list of refs +merge_request: +author: +type: fixed diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index b521d69930a..5617d7c1c41 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -2346,7 +2346,7 @@ module Gitlab end def gitaly_delete_refs(*ref_names) - gitaly_ref_client.delete_refs(refs: ref_names) + gitaly_ref_client.delete_refs(refs: ref_names) if ref_names.any? end def rugged_remove_remote(remote_name) diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index 2b5710ac401..01a51573922 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -600,6 +600,10 @@ describe Gitlab::Git::Repository, seed_helper: true do end end + it 'does not fail when deleting an empty list of refs' do + expect { repo.delete_refs(*[]) }.not_to raise_error + end + it 'raises an error if it failed' do expect { repo.delete_refs('refs\heads\fix') }.to raise_error(Gitlab::Git::Repository::GitError) end