summaryrefslogtreecommitdiff
path: root/lib/gitlab/import_export/repo_restorer.rb
blob: a7e00c7199017bb7a48e35f9261cde14f2de91cd (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
module Gitlab
  module ImportExport
    class RepoRestorer
      include Gitlab::ImportExport::CommandLineUtil
      include Gitlab::ShellAdapter

      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)

        repo_path = @project.repository.path_to_repo
        git_clone_bundle(repo_path: repo_path, bundle_path: @path_to_bundle)
        Gitlab::Git::Repository.create_hooks(repo_path, File.expand_path(Gitlab.config.gitlab_shell.hooks_path))
      rescue => e
        @shared.error(e)
        false
      end
    end
  end
end