Skip to content

Commit 6462c93

Browse files
authored
Merge pull request #612 from umnmsi/tmpdir
Allow specifying tmpdir for git wrapper script
2 parents 545870f + dd073cf commit 6462c93

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

lib/puppet/provider/vcsrepo/git.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
has_features :bare_repositories, :reference_tracking, :ssh_identity, :multiple_remotes,
99
:user, :depth, :branch, :submodules, :safe_directory, :hooks_allowed,
10-
:umask, :http_proxy
10+
:umask, :http_proxy, :tmpdir
1111

1212
def create
1313
check_force
@@ -708,7 +708,7 @@ def git_ssh_with_identity_ssh_command(*args)
708708

709709
# @!visiblity private
710710
def git_ssh_with_identity_ssh_file(*args)
711-
Tempfile.open('git-helper') do |f|
711+
Tempfile.open('git-helper', @resource.value(:tmpdir)) do |f|
712712
f.puts '#!/bin/sh'
713713
f.puts 'SSH_AUTH_SOCKET='
714714
f.puts 'export SSH_AUTH_SOCKET'

lib/puppet/type/vcsrepo.rb

+7
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@
7373
feature :http_proxy,
7474
'The provider supports retrieving repos via HTTP/HTTPS over an HTTP/HTTPS proxy'
7575

76+
feature :tmpdir,
77+
'The provider supports setting the temp directory used for wrapper scripts.'
78+
7679
ensurable do
7780
desc 'Ensure the version control repository.'
7881
attr_accessor :latest
@@ -348,6 +351,10 @@ def insync?(is)
348351
end
349352
end
350353

354+
newparam :tmpdir, required_features: [:tmpdir] do
355+
desc 'The temp directory used for wrapper scripts.'
356+
end
357+
351358
autorequire(:package) do
352359
['git', 'git-core', 'mercurial', 'subversion']
353360
end

spec/unit/puppet/provider/vcsrepo/git_spec.rb

+24
Original file line numberDiff line numberDiff line change
@@ -689,4 +689,28 @@ def branch_a_list(include_branch = nil?)
689689
end
690690
end
691691
end
692+
693+
describe 'tmpdir' do
694+
before(:each) do
695+
resource[:source] = '/path/to/source'
696+
resource[:identity] = '/path/to/identity'
697+
expect(Dir).to receive(:chdir).with('/tmp/test').at_least(:once).and_yield
698+
expect(provider).to receive(:exec_git).with('--version').and_return('1.8.3.1')
699+
end
700+
701+
context 'when set' do
702+
it 'uses tmpdir' do
703+
resource[:tmpdir] = '/custom_tmp'
704+
expect(Tempfile).to receive(:open).with('git-helper', '/custom_tmp')
705+
expect { provider.set_mirror }.not_to raise_error
706+
end
707+
end
708+
709+
context 'when unset' do
710+
it 'uses default' do
711+
expect(Tempfile).to receive(:open).with('git-helper', nil)
712+
expect { provider.set_mirror }.not_to raise_error
713+
end
714+
end
715+
end
692716
end

0 commit comments

Comments
 (0)