diff options
author | Jacob Vosmaer <jacob@gitlab.com> | 2018-01-04 16:34:37 +0100 |
---|---|---|
committer | Jacob Vosmaer <jacob@gitlab.com> | 2018-01-04 16:34:37 +0100 |
commit | 44d15e414348ab7befaa22636b85d1c0d9064d08 (patch) | |
tree | 0dcaff48d62df6272e91355ebdf7643bb48f214a | |
parent | 1e950e3148d31cb3b242cb21be11e04964c2a037 (diff) | |
download | gitlab-ce-44d15e414348ab7befaa22636b85d1c0d9064d08.tar.gz |
get it working
-rw-r--r-- | lib/gitlab/import_export/command_line_util.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/import_export/repo_restorer.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/shell.rb | 4 |
3 files changed, 11 insertions, 1 deletions
diff --git a/lib/gitlab/import_export/command_line_util.rb b/lib/gitlab/import_export/command_line_util.rb index 0135b3c6f22..349f17cf0f8 100644 --- a/lib/gitlab/import_export/command_line_util.rb +++ b/lib/gitlab/import_export/command_line_util.rb @@ -15,6 +15,10 @@ module Gitlab execute(%W(#{git_bin_path} --git-dir=#{repo_path} bundle create #{bundle_path} --all)) end + def git_clone_bundle(repo_path:, bundle_path:) + execute(%W(#{git_bin_path} clone --bare -- #{bundle_path} #{repo_path})) + end + def mkdir_p(path) FileUtils.mkdir_p(path, mode: DEFAULT_MODE) FileUtils.chmod(DEFAULT_MODE, path) diff --git a/lib/gitlab/import_export/repo_restorer.rb b/lib/gitlab/import_export/repo_restorer.rb index 32ca2809b2f..a7e00c71990 100644 --- a/lib/gitlab/import_export/repo_restorer.rb +++ b/lib/gitlab/import_export/repo_restorer.rb @@ -13,7 +13,9 @@ module Gitlab def restore return true unless File.exist?(@path_to_bundle) - gitlab_shell.import_repository(@project.repository_storage_path, @project.disk_path, @path_to_bundle) + repo_path = @project.repository.path_to_repo + git_clone_bundle(repo_path: repo_path, bundle_path: @path_to_bundle) + Gitlab::Git::Repository.create_hooks(repo_path, File.expand_path(Gitlab.config.gitlab_shell.hooks_path)) rescue => e @shared.error(e) false diff --git a/lib/gitlab/shell.rb b/lib/gitlab/shell.rb index 9cdd3d22f18..1d0eae28f82 100644 --- a/lib/gitlab/shell.rb +++ b/lib/gitlab/shell.rb @@ -102,6 +102,10 @@ module Gitlab # # Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/387 def import_repository(storage, name, url) + if url.start_with?('.') || url.start_with?('/') + raise Error.new("don't use disk paths with import_repository: #{url.inspect}") + end + # The timeout ensures the subprocess won't hang forever cmd = gitlab_projects(storage, "#{name}.git") success = cmd.import_project(url, git_timeout) |