gitlab-org--gitlab-foss/lib/gitlab/import_export/command_line_util.rb

40 lines
1.2 KiB
Ruby
Raw Normal View History

module Gitlab
module ImportExport
module CommandLineUtil
def tar_cf(archive:, dir:)
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
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
def tar_with_options(archive:, dir:, options:)
cmd = %W(tar -#{options} #{archive} -C #{dir} .)
_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