summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2019-01-23 23:49:42 +0000
committerRobert Speicher <rspeicher@gmail.com>2019-01-23 23:49:42 +0000
commitde3af288ce4e478acf8ad7a89690e7215a2bf6a0 (patch)
tree6bf3fca388dbcfa404401a97ea28622051717692
parent3effc289ca2765a45867525ba34491008ff6cf04 (diff)
parent100b050b996072cc302a3a7f8fac850ddaab27d4 (diff)
downloadgitlab-ce-de3af288ce4e478acf8ad7a89690e7215a2bf6a0.tar.gz
Merge branch 'sh-remove-bitbucket-mirror-constant' into 'master'
Fix import handling errors in Bitbucket Server importer See merge request gitlab-org/gitlab-ce!24499
-rw-r--r--changelogs/unreleased/sh-remove-bitbucket-mirror-constant.yml5
-rw-r--r--lib/gitlab/bitbucket_server_import/importer.rb4
-rw-r--r--spec/lib/gitlab/bitbucket_server_import/importer_spec.rb17
3 files changed, 20 insertions, 6 deletions
diff --git a/changelogs/unreleased/sh-remove-bitbucket-mirror-constant.yml b/changelogs/unreleased/sh-remove-bitbucket-mirror-constant.yml
new file mode 100644
index 00000000000..8c0b000220f
--- /dev/null
+++ b/changelogs/unreleased/sh-remove-bitbucket-mirror-constant.yml
@@ -0,0 +1,5 @@
+---
+title: Fix import handling errors in Bitbucket Server importer
+merge_request: 24499
+author:
+type: fixed
diff --git a/lib/gitlab/bitbucket_server_import/importer.rb b/lib/gitlab/bitbucket_server_import/importer.rb
index 28cfb46e2d4..dbbedd5dcbe 100644
--- a/lib/gitlab/bitbucket_server_import/importer.rb
+++ b/lib/gitlab/bitbucket_server_import/importer.rb
@@ -132,7 +132,7 @@ module Gitlab
project.repository.fetch_as_mirror(project.import_url, refmap: self.class.refmap, remote_name: REMOTE_NAME)
log_info(stage: 'import_repository', message: 'finished import')
- rescue Gitlab::Shell::Error, Gitlab::Git::RepositoryMirroring::RemoteError => e
+ rescue Gitlab::Shell::Error => e
log_error(stage: 'import_repository', message: 'failed import', error: e.message)
# Expire cache to prevent scenarios such as:
@@ -140,7 +140,7 @@ module Gitlab
# 2. Retried import, repo is broken or not imported but +exists?+ still returns true
project.repository.expire_content_cache if project.repository_exists?
- raise e.message
+ raise
end
# Bitbucket Server keeps tracks of references for open pull requests in
diff --git a/spec/lib/gitlab/bitbucket_server_import/importer_spec.rb b/spec/lib/gitlab/bitbucket_server_import/importer_spec.rb
index 70423823b89..1e90a2ef27f 100644
--- a/spec/lib/gitlab/bitbucket_server_import/importer_spec.rb
+++ b/spec/lib/gitlab/bitbucket_server_import/importer_spec.rb
@@ -21,12 +21,9 @@ describe Gitlab::BitbucketServerImport::Importer do
end
describe '#import_repository' do
- before do
+ it 'adds a remote' do
expect(subject).to receive(:import_pull_requests)
expect(subject).to receive(:delete_temp_branches)
- end
-
- it 'adds a remote' do
expect(project.repository).to receive(:fetch_as_mirror)
.with('http://bitbucket:test@my-bitbucket',
refmap: [:heads, :tags, '+refs/pull-requests/*/to:refs/merge-requests/*/head'],
@@ -34,6 +31,18 @@ describe Gitlab::BitbucketServerImport::Importer do
subject.execute
end
+
+ it 'raises a Gitlab::Shell exception in the fetch' do
+ expect(project.repository).to receive(:fetch_as_mirror).and_raise(Gitlab::Shell::Error)
+
+ expect { subject.execute }.to raise_error(Gitlab::Shell::Error)
+ end
+
+ it 'raises an unhandled exception in the fetch' do
+ expect(project.repository).to receive(:fetch_as_mirror).and_raise(RuntimeError)
+
+ expect { subject.execute }.to raise_error(RuntimeError)
+ end
end
describe '#import_pull_requests' do