2016-04-14 14:57:25 +00:00
|
|
|
module Gitlab
|
2016-03-08 11:35:37 +00:00
|
|
|
module ImportExport
|
|
|
|
class RepoBundler
|
2016-04-14 14:57:25 +00:00
|
|
|
include Gitlab::ImportExport::CommandLineUtil
|
2016-03-08 11:35:37 +00:00
|
|
|
|
|
|
|
attr_reader :full_path
|
|
|
|
|
|
|
|
def initialize(project: , shared: )
|
|
|
|
@project = project
|
|
|
|
@export_path = shared.export_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def bundle
|
2016-03-08 14:53:32 +00:00
|
|
|
return false if @project.empty_repo?
|
|
|
|
@full_path = File.join(@export_path, project_filename)
|
2016-03-08 11:35:37 +00:00
|
|
|
bundle_to_disk
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def bundle_to_disk
|
2016-03-08 14:53:32 +00:00
|
|
|
FileUtils.mkdir_p(@export_path)
|
2016-03-08 11:35:37 +00:00
|
|
|
tar_cf(archive: full_path, dir: path_to_repo)
|
|
|
|
rescue
|
|
|
|
#TODO: handle error
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def project_filename
|
2016-04-22 10:49:37 +00:00
|
|
|
"project.bundle"
|
2016-03-08 11:35:37 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def path_to_repo
|
|
|
|
@project.repository.path_to_repo
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|