Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect home dir for Windows #577

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

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 @@ -734,11 +734,11 @@ def exec_git(*args)
exec_args = {
failonfail: true,
combine: true,
custom_environment: { 'HOME' => Etc.getpwuid(Process.uid).dir }
custom_environment: { 'HOME' => Dir.home },
}

if @resource.value(:user) && @resource.value(:user) != Facter['id'].value
exec_args[:custom_environment] = { 'HOME' => Etc.getpwnam(@resource.value(:user)).dir }
exec_args[:custom_environment] = { 'HOME' => Dir.home(@resource.value(:user)) }
exec_args[:uid] = @resource.value(:user)
end
withumask do
Expand Down
13 changes: 10 additions & 3 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@
"source": "https://github.com/puppetlabs/puppetlabs-vcsrepo",
"project_page": "https://github.com/puppetlabs/puppetlabs-vcsrepo",
"issues_url": "https://github.com/puppetlabs/puppetlabs-vcsrepo/issues",
"dependencies": [

],
"dependencies": [],
"operatingsystem_support": [
{
"operatingsystem": "Windows",
"operatingsystemrelease": [
"10",
"11",
"2019",
"2022"
]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
Expand Down
24 changes: 13 additions & 11 deletions spec/acceptance/clone_repo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
end
end

context 'with with shallow clone' do
context 'with shallow clone' do
pp = <<-MANIFEST
vcsrepo { "#{tmpdir}/testrepo_shallow":
ensure => present,
Expand Down Expand Up @@ -212,10 +212,11 @@
end
end

context 'with with an owner' do
context 'with an owner' do
pp = <<-MANIFEST
user { 'vagrant':
user { 'customowner':
ensure => present,
password => if ($facts['os']['family'] == 'windows') { 'CorrectHorseBatteryStaple0!' },
}
MANIFEST

Expand All @@ -225,7 +226,7 @@
ensure => present,
provider => git,
source => "file://#{tmpdir}/testrepo.git",
owner => 'vagrant',
owner => 'customowner',
safe_directory => true,
}
MANIFEST
Expand All @@ -236,7 +237,7 @@

describe file("#{tmpdir}/testrepo_owner") do
it { is_expected.to be_directory }
it { is_expected.to be_owned_by 'vagrant' }
it { is_expected.to be_owned_by 'customowner' }
end

describe file('/etc/gitconfig') do
Expand All @@ -246,9 +247,9 @@
end
end

context 'with with a group' do
context 'with a group' do
pp = <<-MANIFEST
group { 'vagrant':
group { 'customgroup':
ensure => present,
}
MANIFEST
Expand All @@ -260,7 +261,7 @@
ensure => present,
provider => git,
source => "file://#{tmpdir}/testrepo.git",
group => 'vagrant',
group => 'customgroup',
}
MANIFEST
it 'clones a repo' do
Expand All @@ -270,11 +271,11 @@

describe file("#{tmpdir}/testrepo_group") do
it { is_expected.to be_directory }
it { is_expected.to be_grouped_into 'vagrant' }
it { is_expected.to be_grouped_into 'customgroup' }
end
end

context 'with with excludes' do
context 'with excludes' do
pp = <<-MANIFEST
vcsrepo { "#{tmpdir}/testrepo_excludes":
ensure => present,
Expand All @@ -301,7 +302,7 @@
end
end

context 'with with force' do
context 'with force' do
before(:all) do
run_shell("mkdir -p #{tmpdir}/testrepo_force/folder")
run_shell("touch #{tmpdir}/testrepo_force/temp.txt")
Expand Down Expand Up @@ -369,6 +370,7 @@
user { 'testuser':
ensure => present,
groups => 'testuser',
password => if ($facts['os']['family'] == 'windows') { 'CorrectHorseBatteryStaple0!' },
}
MANIFEST

Expand Down
4 changes: 2 additions & 2 deletions spec/spec_helper_acceptance_local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ def create_repo
PP
LitmusHelper.instance.apply_manifest(pp)
else
unless run_bolt_task('package', 'action' => 'status', 'name' => 'git')
unless LitmusHelper.instance.run_bolt_task('package', 'action' => 'status', 'name' => 'git')
puts 'Git package is required for this module'
exit
end
unless run_bolt_task('package', 'action' => 'status', 'name' => 'subversion')
unless LitmusHelper.instance.run_bolt_task('package', 'action' => 'status', 'name' => 'subversion')
puts 'Subversion package is required for this module'
exit
end
Expand Down
Loading