diff options
author | Igor Drozdov <idrozdov@gitlab.com> | 2019-04-01 17:36:11 +0300 |
---|---|---|
committer | Igor Drozdov <idrozdov@gitlab.com> | 2019-04-01 17:36:11 +0300 |
commit | 04bb35a4b562fd57b14c55645bb1848a50cdef56 (patch) | |
tree | 1bd1ac2af6a5c088ac2529cdbccceeca402d3ebe /lib/gitlab/github_import/importer/repository_importer.rb | |
parent | ade207e575ab846f6d354aaccc1382a6e512dd0d (diff) | |
parent | b8118a65d595040bfce2d83d5e38dd63ebfedb58 (diff) | |
download | gitlab-ce-id-split-self-approval-restrictions.tar.gz |
Merge branch 'master' into id-split-self-approval-restrictionsid-split-self-approval-restrictions
Diffstat (limited to 'lib/gitlab/github_import/importer/repository_importer.rb')
-rw-r--r-- | lib/gitlab/github_import/importer/repository_importer.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/gitlab/github_import/importer/repository_importer.rb b/lib/gitlab/github_import/importer/repository_importer.rb index e2dfb00dcc5..6d48c6a15b4 100644 --- a/lib/gitlab/github_import/importer/repository_importer.rb +++ b/lib/gitlab/github_import/importer/repository_importer.rb @@ -5,6 +5,7 @@ module Gitlab module Importer class RepositoryImporter include Gitlab::ShellAdapter + include Gitlab::Utils::StrongMemoize attr_reader :project, :client, :wiki_formatter @@ -17,7 +18,7 @@ module Gitlab # Returns true if we should import the wiki for the project. # rubocop: disable CodeReuse/ActiveRecord def import_wiki? - client.repository(project.import_source)&.has_wiki && + client_repository&.has_wiki && !project.wiki_repository_exists? && Gitlab::GitalyClient::RemoteService.exists?(wiki_url) end @@ -52,6 +53,7 @@ module Gitlab refmap = Gitlab::GithubImport.refmap project.repository.fetch_as_mirror(project.import_url, refmap: refmap, forced: true, remote_name: 'github') + project.change_head(default_branch) if default_branch true rescue Gitlab::Git::Repository::NoRepository, Gitlab::Shell::Error => e fail_import("Failed to import the repository: #{e.message}") @@ -82,6 +84,18 @@ module Gitlab project.import_state.mark_as_failed(message) false 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 |