diff options
author | James Lopez <james@jameslopez.es> | 2016-06-13 13:43:25 +0300 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2016-06-13 13:43:25 +0300 |
commit | ad68bc63b5e7e8080e82d9febec05397c802d33d (patch) | |
tree | d9508d5bd96c8087d13b88051637bb442e877659 /lib/gitlab/import_export/repo_saver.rb | |
parent | 41c06c311b9c5642f6056d0b34030980ebf507b3 (diff) | |
parent | cc322603945816ed957da7c0efa56e2ef1016569 (diff) |
Merge branches 'feature/project-export' and 'feature/project-import' of gitlab.com:gitlab-org/gitlab-ce into feature/project-import
# Conflicts:
# app/models/project.rb
# db/schema.rb
# lib/gitlab/import_export/import_export_reader.rb
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..07d71c78f33 --- /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) + false + end + + def path_to_repo + @project.repository.path_to_repo + end + end + end +end |