Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/puppet/provider/vcsrepo/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

has_features :bare_repositories, :reference_tracking, :ssh_identity, :multiple_remotes,
:user, :depth, :branch, :submodules, :safe_directory, :hooks_allowed,
:umask, :http_proxy
:umask, :http_proxy, :tmpdir

def create
check_force
Expand Down Expand Up @@ -708,7 +708,7 @@ def git_ssh_with_identity_ssh_command(*args)

# @!visiblity private
def git_ssh_with_identity_ssh_file(*args)
Tempfile.open('git-helper') do |f|
Tempfile.open('git-helper', @resource.value(:tmpdir)) do |f|
f.puts '#!/bin/sh'
f.puts 'SSH_AUTH_SOCKET='
f.puts 'export SSH_AUTH_SOCKET'
Expand Down
7 changes: 7 additions & 0 deletions lib/puppet/type/vcsrepo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
feature :http_proxy,
'The provider supports retrieving repos via HTTP/HTTPS over an HTTP/HTTPS proxy'

feature :tmpdir,
'The provider supports setting the temp directory used for wrapper scripts.'

ensurable do
desc 'Ensure the version control repository.'
attr_accessor :latest
Expand Down Expand Up @@ -348,6 +351,10 @@ def insync?(is)
end
end

newparam :tmpdir, required_features: [:tmpdir] do
desc 'The temp directory used for wrapper scripts.'
end

autorequire(:package) do
['git', 'git-core', 'mercurial', 'subversion']
end
Expand Down
24 changes: 24 additions & 0 deletions spec/unit/puppet/provider/vcsrepo/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -689,4 +689,28 @@ def branch_a_list(include_branch = nil?)
end
end
end

describe 'tmpdir' do
before(:each) do
resource[:source] = '/path/to/source'
resource[:identity] = '/path/to/identity'
expect(Dir).to receive(:chdir).with('/tmp/test').at_least(:once).and_yield
expect(provider).to receive(:exec_git).with('--version').and_return('1.8.3.1')
end

context 'when set' do
it 'uses tmpdir' do
resource[:tmpdir] = '/custom_tmp'
expect(Tempfile).to receive(:open).with('git-helper', '/custom_tmp')
expect { provider.set_mirror }.not_to raise_error
end
end

context 'when unset' do
it 'uses default' do
expect(Tempfile).to receive(:open).with('git-helper', nil)
expect { provider.set_mirror }.not_to raise_error
end
end
end
end