diff options
author | James Lopez <james@jameslopez.es> | 2016-04-15 18:14:28 +0200 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2016-04-15 18:14:28 +0200 |
commit | ae777ea0618e8db8a552a831dc331fe7a7b1fe7a (patch) | |
tree | 0e28d0fac0db940e7fca23518e1764cb34e44f3e /lib/gitlab/import_export/repo_restorer.rb | |
parent | 97c3aff16fa94cee622cd00ffaa2e3a6469c1439 (diff) | |
download | gitlab-ce-ae777ea0618e8db8a552a831dc331fe7a7b1fe7a.tar.gz |
WIP - importing file and repo
Diffstat (limited to 'lib/gitlab/import_export/repo_restorer.rb')
-rw-r--r-- | lib/gitlab/import_export/repo_restorer.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/gitlab/import_export/repo_restorer.rb b/lib/gitlab/import_export/repo_restorer.rb new file mode 100644 index 00000000000..42126cabd97 --- /dev/null +++ b/lib/gitlab/import_export/repo_restorer.rb @@ -0,0 +1,31 @@ +module Gitlab + module ImportExport + class RepoRestorer + include Gitlab::ImportExport::CommandLineUtil + + def initialize(project: , path: ) + @project = project + @path = path + end + + def restore + return false unless File.exists?(@path) + # Move repos dir to 'repositories.old' dir + + FileUtils.mkdir_p(repos_path) + FileUtils.mkdir_p(path_to_repo) + untar_cf(archive: @path, dir: path_to_repo) + end + + private + + def repos_path + Gitlab.config.gitlab_shell.repos_path + end + + def path_to_repo + @project.repository.path_to_repo + end + end + end +end |