Merge pull request #255 from jonnytpuppet/depth_fix
authorDavid Schmitt <david.schmitt@puppetlabs.com>
Mon, 22 Jun 2015 14:27:40 +0000 (15:27 +0100)
committerDavid Schmitt <david.schmitt@puppetlabs.com>
Mon, 22 Jun 2015 14:27:40 +0000 (15:27 +0100)
MODULES-2131 Git provider now takes account of revision property when using depth property.

1  2 
lib/puppet/provider/vcsrepo/git.rb
spec/unit/puppet/provider/vcsrepo/git_spec.rb

@@@ -180,10 -125,10 +180,13 @@@ Puppet::Type.type(:vcsrepo).provide(:gi
      args = ['clone']
      if @resource.value(:depth) and @resource.value(:depth).to_i > 0
        args.push('--depth', @resource.value(:depth).to_s)
+       if @resource.value(:revision)
+         args.push('--branch', @resource.value(:revision).to_s)
+       end
      end
 +    if @resource.value(:branch)
 +      args.push('--branch', @resource.value(:branch).to_s)
 +    end
      if @resource.value(:ensure) == :bare
        args << '--bare'
      end
@@@ -62,9 -60,8 +62,9 @@@ branche
          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(:git).with('clone', '--depth', '1', '--branch', resource.value(:revision),resource.value(:source), resource.value(:path))
          provider.expects(:update_submodules)
 +        provider.expects(:update_remote_url).with("origin", resource.value(:source)).returns false
          provider.expects(:git).with('branch', '-a').returns(branch_a_list(resource.value(:revision)))
          provider.expects(:git).with('checkout', '--force', resource.value(:revision))
          provider.create