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

repo_restorer.rb « import_export « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d1e33ea86784f0960796d6a67774000619ae5d0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
module Gitlab
  module ImportExport
    class RepoRestorer
      include Gitlab::ImportExport::CommandLineUtil

      def initialize(project:, shared:, path_to_bundle:)
        @project = project
        @path_to_bundle = path_to_bundle
        @shared = shared
      end

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

        FileUtils.mkdir_p(path_to_repo)

        git_unbundle(repo_path: path_to_repo, bundle_path: @path_to_bundle) && repo_restore_hooks
      rescue => e
        @shared.error(e)
        false
      end

      private

      def path_to_repo
        @project.repository.path_to_repo
      end

      def repo_restore_hooks
        return true if wiki?

        git_restore_hooks
      end

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