BigW Consortium Gitlab

wiki_repo_saver.rb 798 Bytes
Newer Older
1
module Gitlab
2
  module ImportExport
3 4
    class WikiRepoSaver < RepoSaver
      def save
5
        @wiki = ProjectWiki.new(@project)
6
        return true unless wiki_repository_exists? # it's okay to have no Wiki
7

8
        bundle_to_disk(File.join(@shared.export_path, project_filename))
9 10
      end

11
      def bundle_to_disk(full_path)
12
        mkdir_p(@shared.export_path)
13
        git_bundle(repo_path: path_to_repo, bundle_path: full_path)
14
      rescue => e
15
        @shared.error(e)
16 17 18 19 20
        false
      end

      private

21
      def project_filename
22
        "project.wiki.bundle"
23 24
      end

25 26 27 28
      def path_to_repo
        @wiki.repository.path_to_repo
      end

29
      def wiki_repository_exists?
30
        File.exist?(@wiki.repository.path_to_repo) && !@wiki.repository.empty?
31 32 33 34
      end
    end
  end
end