summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAhmad Sherif <me@ahmadsherif.com>2016-10-19 14:21:27 +0200
committerAhmad Sherif <me@ahmadsherif.com>2016-10-28 11:12:48 +0200
commit6e590af1484c4b98414e0128b58e94342d57b07e (patch)
treefd20b0b8f6d62181d69cd9641183d4e406398d9d
parent66870960af8d8a4cafec4abc529bd073d23fd1e4 (diff)
downloadgitlab-ce-6e590af1484c4b98414e0128b58e94342d57b07e.tar.gz
Check if repository already exists before trying to re-import it
-rw-r--r--app/services/projects/import_service.rb2
-rw-r--r--spec/services/projects/import_service_spec.rb2
2 files changed, 2 insertions, 2 deletions
diff --git a/app/services/projects/import_service.rb b/app/services/projects/import_service.rb
index e466ffa60eb..d7221fe993c 100644
--- a/app/services/projects/import_service.rb
+++ b/app/services/projects/import_service.rb
@@ -29,7 +29,7 @@ module Projects
if unknown_url?
# In this case, we only want to import issues, not a repository.
create_repository
- else
+ elsif !project.repository_exists?
import_repository
end
end
diff --git a/spec/services/projects/import_service_spec.rb b/spec/services/projects/import_service_spec.rb
index ed1384798ab..ab6e8f537ba 100644
--- a/spec/services/projects/import_service_spec.rb
+++ b/spec/services/projects/import_service_spec.rb
@@ -110,7 +110,7 @@ describe Projects::ImportService, services: true do
end
it 'expires existence cache after error' do
- allow_any_instance_of(Project).to receive(:repository_exists?).and_return(true)
+ allow_any_instance_of(Project).to receive(:repository_exists?).and_return(false, true)
expect_any_instance_of(Gitlab::Shell).to receive(:import_repository).with(project.repository_storage_path, project.path_with_namespace, project.import_url).and_raise(Gitlab::Shell::Error.new('Failed to import the repository'))
expect_any_instance_of(Repository).to receive(:expire_emptiness_caches).and_call_original