mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-12 06:06:05 +10:00
40 lines
1.2 KiB
Ruby
40 lines
1.2 KiB
Ruby
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
|
|
|
|
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
|