diff options
author | James Lopez <james@jameslopez.es> | 2016-05-03 11:13:10 +0200 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2016-05-03 11:13:10 +0200 |
commit | 58b0b1a6615958d2ca7628a06898f81b316e6637 (patch) | |
tree | 05978f615fd58fd58620ac967648190e3bf4a0b6 | |
parent | fedfba55194ed51c6a7510c01fa94091e92c71cf (diff) | |
download | gitlab-ce-58b0b1a6615958d2ca7628a06898f81b316e6637.tar.gz |
picking export stuff from the UI branch
-rw-r--r-- | app/services/projects/import_export/export_service.rb | 3 | ||||
-rw-r--r-- | lib/gitlab/import_export/command_line_util.rb | 14 | ||||
-rw-r--r-- | lib/gitlab/import_export/import_export_reader.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/import_export/project_tree_saver.rb | 1 | ||||
-rw-r--r-- | lib/gitlab/import_export/repo_bundler.rb | 1 | ||||
-rw-r--r-- | lib/gitlab/import_export/saver.rb | 1 |
6 files changed, 22 insertions, 2 deletions
diff --git a/app/services/projects/import_export/export_service.rb b/app/services/projects/import_export/export_service.rb index ce13942c5d7..5d5573cba5c 100644 --- a/app/services/projects/import_export/export_service.rb +++ b/app/services/projects/import_export/export_service.rb @@ -1,8 +1,9 @@ module Projects module ImportExport class ExportService < BaseService + def execute(options = {}) - @shared = Gitlab::ImportExport::Shared.new(relative_path: project.path_with_namespace) + @shared = Gitlab::ImportExport::Shared.new(relative_path: File.join(project.path_with_namespace, 'work')) save_project_tree bundle_repo save_all diff --git a/lib/gitlab/import_export/command_line_util.rb b/lib/gitlab/import_export/command_line_util.rb index 7bf4b476b6c..5ff72f5ff8d 100644 --- a/lib/gitlab/import_export/command_line_util.rb +++ b/lib/gitlab/import_export/command_line_util.rb @@ -5,6 +5,14 @@ module Gitlab tar_with_options(archive: archive, dir: dir, options: 'cf') end + def untar_zxf(archive:, dir:) + untar_with_options(archive: archive, dir: dir, options: 'zxf') + end + + def untar_xf(archive:, dir:) + untar_with_options(archive: archive, dir: dir, options: 'xf') + end + def tar_czf(archive:, dir:) tar_with_options(archive: archive, dir: dir, options: 'czf') end @@ -20,6 +28,12 @@ module Gitlab _output, status = Gitlab::Popen.popen(cmd) status.zero? end + + def untar_with_options(archive:, dir:, options:) + cmd = %W(tar -#{options} #{archive} -C #{dir}) + _output, status = Gitlab::Popen.popen(cmd) + status.zero? + end end end end diff --git a/lib/gitlab/import_export/import_export_reader.rb b/lib/gitlab/import_export/import_export_reader.rb index 717d3026f9e..4e46899ec7e 100644 --- a/lib/gitlab/import_export/import_export_reader.rb +++ b/lib/gitlab/import_export/import_export_reader.rb @@ -57,8 +57,10 @@ module Gitlab end def add_new_class(current_key, included_classes_hash, value) + only_except_hash = check_only_and_except(value) + # TODO: refactor this + value = (value.is_a?(Hash) ? value.merge(only_except_hash) : { value => only_except_hash }) if only_except_hash new_hash = { include: value } - new_hash.merge!(check_only_and_except(value)) included_classes_hash[current_key] = new_hash end diff --git a/lib/gitlab/import_export/project_tree_saver.rb b/lib/gitlab/import_export/project_tree_saver.rb index f6fab0fe22d..394411a56c2 100644 --- a/lib/gitlab/import_export/project_tree_saver.rb +++ b/lib/gitlab/import_export/project_tree_saver.rb @@ -24,6 +24,7 @@ module Gitlab false end + # TODO remove magic keyword and move it to a shared config def project_filename "project.json" end diff --git a/lib/gitlab/import_export/repo_bundler.rb b/lib/gitlab/import_export/repo_bundler.rb index 86c9501b708..e719ee2e9e3 100644 --- a/lib/gitlab/import_export/repo_bundler.rb +++ b/lib/gitlab/import_export/repo_bundler.rb @@ -26,6 +26,7 @@ module Gitlab false end + # TODO remove magic keyword and move it to a shared config def project_filename "project.bundle" end diff --git a/lib/gitlab/import_export/saver.rb b/lib/gitlab/import_export/saver.rb index f87e0fdc7ea..634e58e6039 100644 --- a/lib/gitlab/import_export/saver.rb +++ b/lib/gitlab/import_export/saver.rb @@ -14,6 +14,7 @@ module Gitlab def save if compress_and_save remove_storage_path + Rails.logger.info("Saved project export #{archive_file}") archive_file else false |