2016-04-14 14:57:25 +00:00
|
|
|
module Gitlab
|
2016-03-08 11:35:37 +00:00
|
|
|
module ImportExport
|
2016-06-03 10:56:29 +00:00
|
|
|
class RepoSaver
|
2016-04-14 14:57:25 +00:00
|
|
|
include Gitlab::ImportExport::CommandLineUtil
|
2016-03-08 11:35:37 +00:00
|
|
|
|
|
|
|
attr_reader :full_path
|
|
|
|
|
2016-05-16 08:13:00 +00:00
|
|
|
def initialize(project:, shared:)
|
2016-03-08 11:35:37 +00:00
|
|
|
@project = project
|
2016-05-10 15:15:20 +00:00
|
|
|
@shared = shared
|
2016-03-08 11:35:37 +00:00
|
|
|
end
|
|
|
|
|
2016-06-03 10:56:29 +00:00
|
|
|
def save
|
2016-03-08 14:53:32 +00:00
|
|
|
return false if @project.empty_repo?
|
2016-05-13 15:39:03 +00:00
|
|
|
@full_path = File.join(@shared.export_path, ImportExport.project_bundle_filename)
|
2016-03-08 11:35:37 +00:00
|
|
|
bundle_to_disk
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def bundle_to_disk
|
2016-05-10 15:15:20 +00:00
|
|
|
FileUtils.mkdir_p(@shared.export_path)
|
2016-05-05 10:01:18 +00:00
|
|
|
git_bundle(repo_path: path_to_repo, bundle_path: @full_path)
|
2016-05-10 15:15:20 +00:00
|
|
|
rescue => e
|
|
|
|
@shared.error(e.message)
|
2016-03-08 11:35:37 +00:00
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def path_to_repo
|
|
|
|
@project.repository.path_to_repo
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|