summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzegorz@gitlab.com>2018-05-19 05:42:16 +0000
committerStan Hu <stanhu@gmail.com>2018-05-19 04:27:57 -0700
commit47c7771e38b5959c7fc4943f8a99aea344a2ef4d (patch)
tree3febd2056e5f164fd596dd3a3a62931889c9a9fe
parent90be2167d8f447484807d410f5a902d6009062d2 (diff)
downloadgitlab-ce-47c7771e38b5959c7fc4943f8a99aea344a2ef4d.tar.gz
Merge branch 'xeodon/gitlab-ce-fix/45743-master-fix-gitaly-delete-refs' into 'master'10-7-stable-patch-4
Fix error when deleting an empty list of refs Closes #45743 See merge request gitlab-org/gitlab-ce!19053
-rw-r--r--changelogs/unreleased/xeodon-gitlab-ce-fix-45743-master-fix-gitaly-delete-refs.yml5
-rw-r--r--lib/gitlab/git/repository.rb2
-rw-r--r--spec/lib/gitlab/git/repository_spec.rb4
3 files changed, 10 insertions, 1 deletions
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 5af26fb95ed..3ab6c05b382 100644
--- a/lib/gitlab/git/repository.rb
+++ b/lib/gitlab/git/repository.rb
@@ -2339,7 +2339,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 62fcbc041b3..9f9797cc728 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