From 0ea16bba47cf177dc17fa14f20d54d0091a09865 Mon Sep 17 00:00:00 2001 From: Felipe Reyes Date: Thu, 2 Jan 2014 18:13:40 -0300 Subject: Add the option to shallow clones with git The new parameter used to indicate that you want a shallow clone is `:depth` --- spec/unit/puppet/provider/vcsrepo/git_spec.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'spec/unit') diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb index 554645b..c40388f 100644 --- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb @@ -31,6 +31,20 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do end end + context "with shallow clone enable" do + it "should execute 'git clone --depth 1'" do + resource[:revision] = 'only/remote' + resource[:depth] = 1 + Dir.expects(:chdir).with('/').at_least_once.yields + Dir.expects(:chdir).with('/tmp/test').at_least_once.yields + provider.expects(:git).with('clone', '--depth', '1', 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 "with a revision that is not a remote branch" do it "should execute 'git clone' and 'git reset --hard'" do resource[:revision] = 'a-commit-or-tag' -- cgit v1.2.3