diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-01-05 14:18:58 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-01-05 14:18:58 +0000 |
commit | 737f0ae8fdf3bdd23d02da8b7fbfd8e42ba78fdd (patch) | |
tree | ddb33b1b302a7c2ffd045a467628abd545689678 | |
parent | 0f33ac64428b06f194882e23f5167cb9791a7f0f (diff) | |
parent | dcebe1494e35fcd8870b38f311c5176eab6b2a2f (diff) | |
download | gitlab-ce-737f0ae8fdf3bdd23d02da8b7fbfd8e42ba78fdd.tar.gz |
Merge branch 'ban-disk-import' into 'master'
Don't use Gitlab::Shell#import_repository on local paths
See merge request gitlab-org/gitlab-ce!16228
-rw-r--r-- | lib/gitlab/import_export/command_line_util.rb | 5 | ||||
-rw-r--r-- | lib/gitlab/import_export/repo_restorer.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/shell.rb | 4 |
3 files changed, 10 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..dd5d35feab9 100644 --- a/lib/gitlab/import_export/command_line_util.rb +++ b/lib/gitlab/import_export/command_line_util.rb @@ -15,6 +15,11 @@ 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})) + Gitlab::Git::Repository.create_hooks(repo_path, File.expand_path(Gitlab.config.gitlab_shell.hooks_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..d0e5cfcfd3e 100644 --- a/lib/gitlab/import_export/repo_restorer.rb +++ b/lib/gitlab/import_export/repo_restorer.rb @@ -13,7 +13,7 @@ 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) + git_clone_bundle(repo_path: @project.repository.path_to_repo, bundle_path: @path_to_bundle) rescue => e @shared.error(e) false diff --git a/lib/gitlab/shell.rb b/lib/gitlab/shell.rb index b9cc97c9244..564047bbd34 100644 --- a/lib/gitlab/shell.rb +++ b/lib/gitlab/shell.rb @@ -101,6 +101,10 @@ module Gitlab # # Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/874 def import_repository(storage, name, url) + if 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) |