summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2017-04-07 19:02:56 +0000
committerSean McGivern <sean@mcgivern.me.uk>2017-04-07 19:02:56 +0000
commit5d4449151fb576dc927ff1d0ff343fca4645159b (patch)
treeeeebfdef30720dc1f1cc68e1837901c9027b837e
parent9bf3dfd7628f8c9be04709cd177759484808e7f5 (diff)
parentd4058995da7d60200300857bff8791377f72b0d6 (diff)
downloadgitlab-ce-5d4449151fb576dc927ff1d0ff343fca4645159b.tar.gz
Merge branch 'fix-github-import-rake-task' into 'master'
Fix rake test to import Github repositories See merge request !10549
-rw-r--r--lib/tasks/import.rake11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/tasks/import.rake b/lib/tasks/import.rake
index 350afeb5c0b..15131fbf755 100644
--- a/lib/tasks/import.rake
+++ b/lib/tasks/import.rake
@@ -48,9 +48,16 @@ class NewImporter < ::Gitlab::GithubImport::Importer
begin
raise 'Blocked import URL.' if Gitlab::UrlBlocker.blocked_url?(project.import_url)
- gitlab_shell.import_repository(project.repository_storage_path, project.path_with_namespace, project.import_url)
+ project.create_repository
+ project.repository.add_remote(project.import_type, project.import_url)
+ project.repository.set_remote_as_mirror(project.import_type)
+ project.repository.fetch_remote(project.import_type, forced: true)
+ project.repository.remove_remote(project.import_type)
rescue => e
- project.repository.before_import if project.repository_exists?
+ # Expire cache to prevent scenarios such as:
+ # 1. First import failed, but the repo was imported successfully, so +exists?+ returns true
+ # 2. Retried import, repo is broken or not imported but +exists?+ still returns true
+ project.repository.expire_content_cache if project.repository_exists?
raise "Error importing repository #{project.import_url} into #{project.path_with_namespace} - #{e.message}"
end