Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-06-03 13:56:29 +0300
committerJames Lopez <james@jameslopez.es>2016-06-03 13:56:29 +0300
commit9d0038f2d7663419c34eda7675d15d1a40478947 (patch)
tree17ea0769c841f6dd111abd4e6c899bfb610b326c /lib/gitlab/import_export/repo_saver.rb
parent398f0071a6b77a7e26e612b38105ae4bd702ef22 (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.rb34
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