2016-04-14 14:57:25 +00:00
|
|
|
module Gitlab
|
2016-03-07 17:26:15 +00:00
|
|
|
module ImportExport
|
|
|
|
class ProjectTreeSaver
|
|
|
|
attr_reader :full_path
|
|
|
|
|
2016-05-06 11:40:02 +00:00
|
|
|
def initialize(project:, shared:)
|
2016-03-07 17:26:15 +00:00
|
|
|
@project = project
|
2016-05-10 15:15:20 +00:00
|
|
|
@shared = shared
|
2016-05-13 15:39:03 +00:00
|
|
|
@full_path = File.join(@shared.export_path, ImportExport.project_filename)
|
2016-03-07 17:26:15 +00:00
|
|
|
end
|
|
|
|
|
2016-05-06 11:40:02 +00:00
|
|
|
def save
|
2016-05-17 14:28:27 +00:00
|
|
|
FileUtils.mkdir_p(@shared.export_path)
|
|
|
|
|
2016-03-07 17:26:15 +00:00
|
|
|
File.write(full_path, project_json_tree)
|
|
|
|
true
|
2016-05-10 15:15:20 +00:00
|
|
|
rescue => e
|
2016-05-13 10:33:13 +00:00
|
|
|
@shared.error(e)
|
2016-03-07 17:26:15 +00:00
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2016-05-06 11:40:02 +00:00
|
|
|
private
|
|
|
|
|
2016-03-07 17:26:15 +00:00
|
|
|
def project_json_tree
|
2016-06-13 19:18:26 +00:00
|
|
|
@project.to_json(Gitlab::ImportExport::Reader.new(shared: @shared).project_tree)
|
2016-03-07 17:26:15 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|