diff options
author | Michael Kozono <mkozono@gmail.com> | 2018-03-09 01:16:21 +0300 |
---|---|---|
committer | Michael Kozono <mkozono@gmail.com> | 2018-03-14 00:45:17 +0300 |
commit | 1f311a9caa9b3ac3d6e0cfe339390b0949632ae3 (patch) | |
tree | 93f203511872277035b2e4fe7f78d0c32bc0960a /lib/gitlab/project_transfer.rb | |
parent | ea01d4752f041afead7677872ba076682a6620db (diff) |
Fix moving local files during namespace transfer
Diffstat (limited to 'lib/gitlab/project_transfer.rb')
-rw-r--r-- | lib/gitlab/project_transfer.rb | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/gitlab/project_transfer.rb b/lib/gitlab/project_transfer.rb index 1bba0b78e2f..690c38737c0 100644 --- a/lib/gitlab/project_transfer.rb +++ b/lib/gitlab/project_transfer.rb @@ -1,13 +1,19 @@ module Gitlab + # This class is used to move local, unhashed files owned by projects to their new location class ProjectTransfer - def move_project(project_path, namespace_path_was, namespace_path) - new_namespace_folder = File.join(root_dir, namespace_path) - FileUtils.mkdir_p(new_namespace_folder) unless Dir.exist?(new_namespace_folder) - from = File.join(root_dir, namespace_path_was, project_path) - to = File.join(root_dir, namespace_path, project_path) + # nil parent_path (or parent_path_was) represents a root namespace + def move_namespace(path, parent_path_was, parent_path) + parent_path_was ||= '' + parent_path ||= '' + new_parent_folder = File.join(root_dir, parent_path) + FileUtils.mkdir_p(new_parent_folder) + from = File.join(root_dir, parent_path_was, path) + to = File.join(root_dir, parent_path, path) move(from, to, "") end + alias_method :move_project, :move_namespace + def rename_project(path_was, path, namespace_path) base_dir = File.join(root_dir, namespace_path) move(path_was, path, base_dir) |