BigW Consortium Gitlab

repo_restorer.rb 820 Bytes
Newer Older
1 2 3 4 5
module Gitlab
  module ImportExport
    class RepoRestorer
      include Gitlab::ImportExport::CommandLineUtil

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

      def restore
13
        return true unless File.exist?(@path_to_bundle)
14

15
        mkdir_p(path_to_repo)
16

17
        git_unbundle(repo_path: path_to_repo, bundle_path: @path_to_bundle) && repo_restore_hooks
18
      rescue => e
19
        @shared.error(e)
James Lopez committed
20
        false
21 22 23 24 25 26 27
      end

      private

      def path_to_repo
        @project.repository.path_to_repo
      end
28 29 30 31 32 33 34 35 36 37

      def repo_restore_hooks
        return true if wiki?

        git_restore_hooks
      end

      def wiki?
        @project.class.name == 'ProjectWiki'
      end
38 39 40
    end
  end
end