if @resource.value(:remote) != 'origin'
args.push('--origin', @resource.value(:remote))
end
- if !File.exist?(File.join(@resource.value(:path), '.git'))
+ if !working_copy_exists?
args.push(source, path)
Dir.chdir("/") do
git_with_identity(*args)
end
def get_revision(rev)
+ if @resource.value(:force) && working_copy_exists?
+ create
+ end
if !working_copy_exists?
create
end
end
newvalue :latest, :required_features => [:reference_tracking] do
- if provider.exists?
+ if provider.exists? && !@resource.value(:force)
if provider.respond_to?(:update_references)
provider.update_references
end
prov = @resource.provider
if prov
if prov.working_copy_exists?
+ if @resource.value(:force)
+ notice "Deleting current repository before recloning"
+ prov.destroy
+ notice "Create repository from latest"
+ prov.create
+ end
(@should.include?(:latest) && prov.latest?) ? :latest : :present
elsif prov.class.feature?(:bare_repositories) and prov.bare_exists?
:bare
:revision => '2634',
:source => 'git@repo',
:path => '/tmp/test',
+ :force => false
})}
let(:provider) { resource.provider }
provider.expects(:convert_working_copy_to_bare)
provider.create
end
+ it "should clone overtop it using force" do
+ resource[:force] = true
+ Dir.expects(:chdir).with('/').at_least_once.yields
+ Dir.expects(:chdir).with('/tmp/test').at_least_once.yields
+ provider.expects(:path_exists?).returns(true)
+ provider.expects(:path_empty?).returns(false)
+ provider.destroy
+ provider.expects(:git).with('clone',resource.value(:source), resource.value(:path))
+ provider.expects(:update_submodules)
+ provider.expects(:git).with('branch', '-a').returns(resource.value(:revision))
+ provider.expects(:git).with('checkout', '--force', resource.value(:revision))
+ provider.create
+ end
end
context "when the path is not empty and not a repository" do
it "should raise an exception" do
- expects_directory?(true)
+ provider.expects(:path_exists?).returns(true)
provider.expects(:path_empty?).returns(false)
+ provider.expects(:working_copy_exists?).returns(false)
proc { provider.create }.should raise_error(Puppet::Error)
end
end
end
end
- describe 'convert_bare_to_working_copy' do
+ describe 'convert_bare_to_working_copy' do
it do
FileUtils.expects(:mv).returns(true)
FileUtils.expects(:mkdir).returns(true)