mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-19 01:26:08 +10:00
38 lines
774 B
Ruby
38 lines
774 B
Ruby
module Gitlab
|
|
module ImportExport
|
|
class ProjectTreeSaver
|
|
attr_reader :full_path
|
|
|
|
def initialize(project: , shared: )
|
|
@project = project
|
|
@export_path = shared.export_path
|
|
end
|
|
|
|
def save
|
|
@full_path = File.join(@export_path, project_filename)
|
|
save_to_disk
|
|
end
|
|
|
|
private
|
|
|
|
def save_to_disk
|
|
FileUtils.mkdir_p(@export_path)
|
|
File.write(full_path, project_json_tree)
|
|
true
|
|
rescue
|
|
# TODO: handle error
|
|
false
|
|
end
|
|
|
|
# TODO remove magic keyword and move it to a shared config
|
|
def project_filename
|
|
"project.json"
|
|
end
|
|
|
|
def project_json_tree
|
|
@project.to_json(Gitlab::ImportExport.project_tree)
|
|
end
|
|
end
|
|
end
|
|
end
|