2016-04-14 14:57:25 +00:00
|
|
|
module Gitlab
|
2016-03-08 11:35:37 +00:00
|
|
|
module ImportExport
|
|
|
|
module CommandLineUtil
|
|
|
|
def tar_cf(archive:, dir:)
|
2016-04-14 14:57:25 +00:00
|
|
|
tar_with_options(archive: archive, dir: dir, options: 'cf')
|
|
|
|
end
|
|
|
|
|
2016-05-03 09:13:10 +00:00
|
|
|
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
|
|
|
|
|
2016-04-14 14:57:25 +00:00
|
|
|
def tar_czf(archive:, dir:)
|
|
|
|
tar_with_options(archive: archive, dir: dir, options: 'czf')
|
2016-03-08 11:35:37 +00:00
|
|
|
end
|
2016-03-08 17:17:57 +00:00
|
|
|
|
|
|
|
def git_bundle(git_bin_path: Gitlab.config.git.bin_path, repo_path:, bundle_path:)
|
|
|
|
cmd = %W(#{git_bin_path} --git-dir=#{repo_path} bundle create #{bundle_path} --all)
|
|
|
|
_output, status = Gitlab::Popen.popen(cmd)
|
|
|
|
status.zero?
|
|
|
|
end
|
2016-04-14 14:57:25 +00:00
|
|
|
|
|
|
|
def tar_with_options(archive:, dir:, options:)
|
|
|
|
cmd = %W(tar -#{options} #{archive} -C #{dir} .)
|
|
|
|
_output, status = Gitlab::Popen.popen(cmd)
|
|
|
|
status.zero?
|
|
|
|
end
|
2016-05-03 09:13:10 +00:00
|
|
|
|
|
|
|
def untar_with_options(archive:, dir:, options:)
|
|
|
|
cmd = %W(tar -#{options} #{archive} -C #{dir})
|
|
|
|
_output, status = Gitlab::Popen.popen(cmd)
|
|
|
|
status.zero?
|
|
|
|
end
|
2016-03-08 11:35:37 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|