diff options
author | Robert Speicher <robert@gitlab.com> | 2018-01-03 20:18:49 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2018-01-03 20:18:49 +0000 |
commit | 034a21ba4dc0acb12abbb70664a1a7215d9dd42c (patch) | |
tree | 5fe35a4a38a802939c53048273c51c2ea0f758d8 /lib | |
parent | 7dea756ffa90d8d0449a138c5d9229334732383a (diff) | |
parent | 14336c0bda493a870ffeed86379b274c522fe804 (diff) | |
download | gitlab-ce-034a21ba4dc0acb12abbb70664a1a7215d9dd42c.tar.gz |
Merge branch 'da-handle-hashed-storage-repos-using-repo-import-task' into 'master'
Handle GitLab hashed storage repositories using the repo import task
Closes #39870
See merge request gitlab-org/gitlab-ce!16027
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/bare_repository_import/importer.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/bare_repository_import/repository.rb | 37 |
2 files changed, 30 insertions, 11 deletions
diff --git a/lib/gitlab/bare_repository_import/importer.rb b/lib/gitlab/bare_repository_import/importer.rb index 64e41d42709..709a901aa77 100644 --- a/lib/gitlab/bare_repository_import/importer.rb +++ b/lib/gitlab/bare_repository_import/importer.rb @@ -14,7 +14,7 @@ module Gitlab repos_to_import.each do |repo_path| bare_repo = Gitlab::BareRepositoryImport::Repository.new(import_path, repo_path) - if bare_repo.hashed? || bare_repo.wiki? + unless bare_repo.processable? log " * Skipping repo #{bare_repo.repo_path}".color(:yellow) next @@ -62,6 +62,8 @@ module Gitlab if project.persisted? && mv_repo(project) log " * Created #{project.name} (#{project_full_path})".color(:green) + project.write_repository_config + ProjectCacheWorker.perform_async(project.id) else log " * Failed trying to create #{project.name} (#{project_full_path})".color(:red) diff --git a/lib/gitlab/bare_repository_import/repository.rb b/lib/gitlab/bare_repository_import/repository.rb index fa7891c8dcc..85b79362196 100644 --- a/lib/gitlab/bare_repository_import/repository.rb +++ b/lib/gitlab/bare_repository_import/repository.rb @@ -6,39 +6,56 @@ module Gitlab def initialize(root_path, repo_path) @root_path = root_path @repo_path = repo_path - @root_path << '/' unless root_path.ends_with?('/') + full_path = + if hashed? && !wiki? + repository.config.get('gitlab.fullpath') + else + repo_relative_path + end + # Split path into 'all/the/namespaces' and 'project_name' - @group_path, _, @project_name = repo_relative_path.rpartition('/') + @group_path, _, @project_name = full_path.to_s.rpartition('/') end def wiki_exists? File.exist?(wiki_path) end - def wiki? - @wiki ||= repo_path.end_with?('.wiki.git') - end - def wiki_path @wiki_path ||= repo_path.sub(/\.git$/, '.wiki.git') end - def hashed? - @hashed ||= group_path.start_with?('@hashed') - end - def project_full_path @project_full_path ||= "#{group_path}/#{project_name}" end + def processable? + return false if wiki? + return false if hashed? && (group_path.blank? || project_name.blank?) + + true + end + private + def wiki? + @wiki ||= repo_path.end_with?('.wiki.git') + end + + def hashed? + @hashed ||= repo_relative_path.include?('@hashed') + end + def repo_relative_path # Remove root path and `.git` at the end repo_path[@root_path.size...-4] end + + def repository + @repository ||= Rugged::Repository.new(repo_path) + end end end end |