diff options
author | James Lopez <james@jameslopez.es> | 2016-06-03 13:56:29 +0300 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2016-06-03 13:56:29 +0300 |
commit | 9d0038f2d7663419c34eda7675d15d1a40478947 (patch) | |
tree | 17ea0769c841f6dd111abd4e6c899bfb610b326c /lib/gitlab/import_export/repo_saver.rb | |
parent | 398f0071a6b77a7e26e612b38105ae4bd702ef22 (diff) |
started refactoring a bunch of stuff based on feedback
Diffstat (limited to 'lib/gitlab/import_export/repo_saver.rb')
-rw-r--r-- | lib/gitlab/import_export/repo_saver.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/gitlab/import_export/repo_saver.rb b/lib/gitlab/import_export/repo_saver.rb new file mode 100644 index 00000000000..14174873625 --- /dev/null +++ b/lib/gitlab/import_export/repo_saver.rb @@ -0,0 +1,34 @@ +module Gitlab + module ImportExport + class RepoSaver + include Gitlab::ImportExport::CommandLineUtil + + attr_reader :full_path + + def initialize(project:, shared:) + @project = project + @shared = shared + end + + def save + return false if @project.empty_repo? + @full_path = File.join(@shared.export_path, ImportExport.project_bundle_filename) + bundle_to_disk + end + + private + + def bundle_to_disk + FileUtils.mkdir_p(@shared.export_path) + git_bundle(repo_path: path_to_repo, bundle_path: @full_path) + rescue => e + @shared.error(e.message) + false + end + + def path_to_repo + @project.repository.path_to_repo + end + end + end +end |