| ... | @@ -5,6 +5,7 @@ module Gitlab |
... | @@ -5,6 +5,7 @@ module Gitlab |
|
|
module Importer
|
|
module Importer
|
|
|
class RepositoryImporter
|
|
class RepositoryImporter
|
|
|
include Gitlab::ShellAdapter
|
|
include Gitlab::ShellAdapter
|
|
|
|
include Gitlab::Utils::StrongMemoize
|
|
|
|
|
|
|
|
attr_reader :project, :client, :wiki_formatter
|
|
attr_reader :project, :client, :wiki_formatter
|
|
|
|
|
|
| ... | @@ -17,7 +18,7 @@ module Gitlab |
... | @@ -17,7 +18,7 @@ module Gitlab |
|
|
# Returns true if we should import the wiki for the project.
|
|
# Returns true if we should import the wiki for the project.
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
|
|
def import_wiki?
|
|
def import_wiki?
|
|
|
client.repository(project.import_source)&.has_wiki &&
|
|
client_repository&.has_wiki &&
|
|
|
!project.wiki_repository_exists? &&
|
|
!project.wiki_repository_exists? &&
|
|
|
Gitlab::GitalyClient::RemoteService.exists?(wiki_url)
|
|
Gitlab::GitalyClient::RemoteService.exists?(wiki_url)
|
|
|
end
|
|
end
|
| ... | @@ -52,6 +53,7 @@ module Gitlab |
... | @@ -52,6 +53,7 @@ module Gitlab |
|
|
refmap = Gitlab::GithubImport.refmap
|
|
refmap = Gitlab::GithubImport.refmap
|
|
|
project.repository.fetch_as_mirror(project.import_url, refmap: refmap, forced: true, remote_name: 'github')
|
|
project.repository.fetch_as_mirror(project.import_url, refmap: refmap, forced: true, remote_name: 'github')
|
|
|
|
|
|
|
|
|
project.change_head(default_branch) if default_branch
|
|
|
true
|
|
true
|
|
|
rescue Gitlab::Git::Repository::NoRepository, Gitlab::Shell::Error => e
|
|
rescue Gitlab::Git::Repository::NoRepository, Gitlab::Shell::Error => e
|
|
|
fail_import("Failed to import the repository: #{e.message}")
|
|
fail_import("Failed to import the repository: #{e.message}")
|
| ... | @@ -82,6 +84,18 @@ module Gitlab |
... | @@ -82,6 +84,18 @@ module Gitlab |
|
|
project.import_state.mark_as_failed(message)
|
|
project.import_state.mark_as_failed(message)
|
|
|
false
|
|
false
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def default_branch
|
|
|
|
client_repository&.default_branch
|
|
|
|
end
|
|
|
|
|
|
|
|
def client_repository
|
|
|
|
strong_memoize(:client_repository) do
|
|
|
|
client.repository(project.import_source)
|
|
|
|
end
|
|
|
|
end
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
| ... | |
... | |
| ... | | ... | |