From ec4109d413f6161b43ad4cc1a6251af30d3bcf03 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Thu, 12 Jul 2018 23:17:05 -0700 Subject: Make Connection#post consistent with Connection#get and add specs --- lib/gitlab/bitbucket_server_import/importer.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'lib/gitlab/bitbucket_server_import') diff --git a/lib/gitlab/bitbucket_server_import/importer.rb b/lib/gitlab/bitbucket_server_import/importer.rb index e948a038e8e..580dc0bb852 100644 --- a/lib/gitlab/bitbucket_server_import/importer.rb +++ b/lib/gitlab/bitbucket_server_import/importer.rb @@ -90,12 +90,11 @@ module Gitlab shas.each do |branch_name, sha| next if sha_exists?(sha) - response = client.create_branch(project_key, repository_slug, branch_name, sha) - - if response.success? + begin + client.create_branch(project_key, repository_slug, branch_name, sha) branches_created << branch_name - else - Rails.logger.warn("BitbucketServerImporter: Unable to recreate branch for SHA #{sha}: #{response.code}") + rescue BitbucketServer::Connection::ConnectionError => e + Rails.logger.warn("BitbucketServerImporter: Unable to recreate branch for SHA #{sha}: #{e}") end end end -- cgit v1.2.1