BigW Consortium Gitlab

repo_saver.rb 758 Bytes
Newer Older
1
module Gitlab
2
  module ImportExport
3
    class RepoSaver
4
      include Gitlab::ImportExport::CommandLineUtil
5 6 7

      attr_reader :full_path

8
      def initialize(project:, shared:)
9
        @project = project
10
        @shared = shared
11 12
      end

13
      def save
14
        return true if @project.empty_repo? # it's ok to have no repo
James Lopez committed
15

James Lopez committed
16
        @full_path = File.join(@shared.export_path, ImportExport.project_bundle_filename)
17 18 19 20 21 22
        bundle_to_disk
      end

      private

      def bundle_to_disk
23
        mkdir_p(@shared.export_path)
24
        git_bundle(repo_path: path_to_repo, bundle_path: @full_path)
25
      rescue => e
26
        @shared.error(e)
27 28 29 30 31 32 33 34 35
        false
      end

      def path_to_repo
        @project.repository.path_to_repo
      end
    end
  end
end