2016-04-14 10:57:25 -04:00
|
|
|
module Gitlab
|
2016-03-08 06:35:37 -05:00
|
|
|
module ImportExport
|
2016-06-03 06:56:29 -04:00
|
|
|
class RepoSaver
|
2016-04-14 10:57:25 -04:00
|
|
|
include Gitlab::ImportExport::CommandLineUtil
|
2016-03-08 06:35:37 -05:00
|
|
|
|
|
|
|
attr_reader :full_path
|
|
|
|
|
2016-05-16 04:13:00 -04:00
|
|
|
def initialize(project:, shared:)
|
2016-03-08 06:35:37 -05:00
|
|
|
@project = project
|
2016-05-10 11:15:20 -04:00
|
|
|
@shared = shared
|
2016-03-08 06:35:37 -05:00
|
|
|
end
|
|
|
|
|
2016-06-03 06:56:29 -04:00
|
|
|
def save
|
2016-07-18 05:02:07 -04:00
|
|
|
return true if @project.empty_repo? # it's ok to have no repo
|
2016-06-14 04:15:20 -04:00
|
|
|
|
2016-05-13 11:39:03 -04:00
|
|
|
@full_path = File.join(@shared.export_path, ImportExport.project_bundle_filename)
|
2016-03-08 06:35:37 -05:00
|
|
|
bundle_to_disk
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def bundle_to_disk
|
2016-09-29 11:17:22 -04:00
|
|
|
mkdir_p(@shared.export_path)
|
2016-05-05 06:01:18 -04:00
|
|
|
git_bundle(repo_path: path_to_repo, bundle_path: @full_path)
|
2016-05-10 11:15:20 -04:00
|
|
|
rescue => e
|
2016-05-13 06:33:13 -04:00
|
|
|
@shared.error(e)
|
2016-03-08 06:35:37 -05:00
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def path_to_repo
|
|
|
|
@project.repository.path_to_repo
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|