From 36d75be393eaa8385a4ba121b11b9d8e02ad52de Mon Sep 17 00:00:00 2001 From: Zeger-Jan van de Weg Date: Thu, 14 Jun 2018 10:13:15 +0200 Subject: Move TagNames to mandatory through Gitaly Closes: https://gitlab.com/gitlab-org/gitaly/issues/220 --- lib/gitlab/git/repository.rb | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index 6e149984a49..37c0af3622e 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -150,12 +150,8 @@ module Gitlab # Returns an Array of branch names # sorted by name ASC def branch_names - gitaly_migrate(:branch_names, status: Gitlab::GitalyClient::MigrationStatus::OPT_OUT) do |is_enabled| - if is_enabled - gitaly_ref_client.branch_names - else - branches.map(&:name) - end + wrapped_gitaly_errors do + gitaly_ref_client.branch_names end end @@ -268,7 +264,9 @@ module Gitlab # Returns an Array of tag names def tag_names - gitaly_ref_client.tag_names + wrapped_gitaly_errors do + gitaly_ref_client.tag_names + end end # Returns an Array of Tags @@ -1420,6 +1418,16 @@ module Gitlab raise CommandError.new(e) end + def wrapped_gitaly_errors(&block) + yield block + rescue GRPC::NotFound => e + raise NoRepository.new(e) + rescue GRPC::InvalidArgument => e + raise ArgumentError.new(e) + rescue GRPC::BadStatus => e + raise CommandError.new(e) + end + def clean_stale_repository_files gitaly_migrate(:repository_cleanup, status: Gitlab::GitalyClient::MigrationStatus::OPT_OUT) do |is_enabled| gitaly_repository_client.cleanup if is_enabled && exists? -- cgit v1.2.1