Commit 99d87d86 authored by James Lopez's avatar James Lopez

WIP - added wiki repo bundler

parent 556cafa4
......@@ -6,6 +6,12 @@ module Projects
_output, status = Gitlab::Popen.popen(cmd)
status.zero?
end
def git_bundle(git_bin_path: Gitlab.config.git.bin_path, repo_path:, bundle_path:)
cmd = %W(#{git_bin_path} --git-dir=#{repo_path} bundle create #{bundle_path} --all)
_output, status = Gitlab::Popen.popen(cmd)
status.zero?
end
end
end
end
module Projects
module ImportExport
class WikiRepoBundler < RepoBundler
def bundle
@wiki = ProjectWiki.new(@project)
return false if !wiki?
@full_path = File.join(@export_path, project_filename)
bundle_to_disk
end
def bundle_to_disk
FileUtils.mkdir_p(@export_path)
git_bundle(repo_path: path_to_repo, bundle_path: @full_path)
rescue
#TODO: handle error
false
end
private
def path_to_repo
@wiki.repository.path_to_repo
end
def wiki?
File.exists?(@wiki.repository.path_to_repo) && !@wiki.repository.empty?
end
end
end
end
require 'spec_helper'
describe Projects::ImportExport::WikiRepoBundler, services: true do
describe :bundle do
let(:user) { create(:user) }
let!(:project) { create(:project, :public, name: 'searchable_project') }
let(:export_path) { "#{Dir::tmpdir}/project_tree_saver_spec" }
let(:shared) { Projects::ImportExport::Shared.new(relative_path: project.path_with_namespace) }
let(:wiki_bundler) { Projects::ImportExport::WikiRepoBundler.new(project: project, shared: shared) }
before(:each) do
project.team << [user, :master]
allow_any_instance_of(Projects::ImportExport).to receive(:storage_path).and_return(export_path)
end
after(:each) do
FileUtils.rm_rf(export_path)
end
it 'bundles the repo successfully' do
expect(wiki_bundler.bundle).to be true
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment