Commit 58b0b1a6 authored by James Lopez's avatar James Lopez

picking export stuff from the UI branch

parent fedfba55
module Projects module Projects
module ImportExport module ImportExport
class ExportService < BaseService class ExportService < BaseService
def execute(options = {}) 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 save_project_tree
bundle_repo bundle_repo
save_all save_all
......
...@@ -5,6 +5,14 @@ module Gitlab ...@@ -5,6 +5,14 @@ module Gitlab
tar_with_options(archive: archive, dir: dir, options: 'cf') tar_with_options(archive: archive, dir: dir, options: 'cf')
end 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:) def tar_czf(archive:, dir:)
tar_with_options(archive: archive, dir: dir, options: 'czf') tar_with_options(archive: archive, dir: dir, options: 'czf')
end end
...@@ -20,6 +28,12 @@ module Gitlab ...@@ -20,6 +28,12 @@ module Gitlab
_output, status = Gitlab::Popen.popen(cmd) _output, status = Gitlab::Popen.popen(cmd)
status.zero? status.zero?
end 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 end
end end
...@@ -57,8 +57,10 @@ module Gitlab ...@@ -57,8 +57,10 @@ module Gitlab
end end
def add_new_class(current_key, included_classes_hash, value) 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 = { include: value }
new_hash.merge!(check_only_and_except(value))
included_classes_hash[current_key] = new_hash included_classes_hash[current_key] = new_hash
end end
......
...@@ -24,6 +24,7 @@ module Gitlab ...@@ -24,6 +24,7 @@ module Gitlab
false false
end end
# TODO remove magic keyword and move it to a shared config
def project_filename def project_filename
"project.json" "project.json"
end end
......
...@@ -26,6 +26,7 @@ module Gitlab ...@@ -26,6 +26,7 @@ module Gitlab
false false
end end
# TODO remove magic keyword and move it to a shared config
def project_filename def project_filename
"project.bundle" "project.bundle"
end end
......
...@@ -14,6 +14,7 @@ module Gitlab ...@@ -14,6 +14,7 @@ module Gitlab
def save def save
if compress_and_save if compress_and_save
remove_storage_path remove_storage_path
Rails.logger.info("Saved project export #{archive_file}")
archive_file archive_file
else else
false false
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment