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

(naïvely) replace git clone/pull execs with vcsrepo #110

Closed
wants to merge 1 commit into from
Closed
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
17 changes: 6 additions & 11 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,18 @@
require rbenv::dependencies
}

exec { "rbenv::checkout ${user}":
command => "git clone https://github.com/sstephenson/rbenv.git ${root_path}",
user => $user,
group => $group,
creates => $root_path,
path => ['/bin', '/usr/bin', '/usr/sbin'],
timeout => 100,
cwd => $home_path,
require => Package['git'],
vcsrepo { $root_path:
source => 'https://github.com/sstephenson/rbenv.git',
owern => $user,
group => $group,
}

file { "rbenv::rbenvrc ${user}":
path => $rbenvrc,
owner => $user,
group => $group,
content => template('rbenv/dot.rbenvrc.erb'),
require => Exec["rbenv::checkout ${user}"],
require => Vcsrepo[$root_path],
}

exec { "rbenv::shrc ${user}":
Expand All @@ -50,6 +45,6 @@
owner => $user,
group => $group,
path => "${root_path}/cache",
require => Exec["rbenv::checkout ${user}"]
require => Vcsrepo[$root_path]
}
}
25 changes: 5 additions & 20 deletions manifests/plugin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,15 @@
path => $plugins,
owner => $user,
group => $group,
require => Exec["rbenv::checkout ${user}"],
require => Vcsrepo[$root_path],
}
}

exec { "rbenv::plugin::checkout ${user} ${plugin_name}":
command => "git clone ${source} ${destination}",
user => $user,
vcsrepo { $destination:
ensure => latest,
source => $source,
owner => $user,
group => $group,
creates => $destination,
path => ['/bin', '/usr/bin', '/usr/sbin'],
timeout => $timeout,
cwd => $home_path,
require => File["rbenv::plugins ${user}"],
}

exec { "rbenv::plugin::update ${user} ${plugin_name}":
command => 'git pull',
user => $user,
group => $group,
path => ['/bin', '/usr/bin', '/usr/sbin'],
timeout => $timeout,
cwd => $destination,
require => Exec["rbenv::plugin::checkout ${user} ${plugin_name}"],
onlyif => 'git remote update; if [ "$(git rev-parse @{0})" = "$(git rev-parse @{u})" ]; then return 0; else return 1; fi ]',
}

}
4 changes: 2 additions & 2 deletions spec/defines/rbenv__install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

context 'install rbenv' do
it "clones rbenv from the official repository" do
should contain_exec("rbenv::checkout #{user}").
with_command("git clone https://github.com/sstephenson/rbenv.git /home/#{user}/.rbenv")
should contain_vcsrepo(" /home/#{user}/.rbenv").
with_source("https://github.com/sstephenson/rbenv.git")
end

it "appends in a rc file, a command to include .rbenv/bin folder in PATH env variable" do
Expand Down
24 changes: 5 additions & 19 deletions spec/defines/rbenv__plugin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,12 @@

let(:target_path) { "#{dot_rbenv}/plugins/#{plugin_name}" }

it 'clones repository to the right path' do
should contain_exec("rbenv::plugin::checkout #{user} #{plugin_name}").with(
:command => "git clone #{source} #{target_path}",
:user => user,
:creates => target_path,
it 'clones repository to the right path (in the latest version)' do
should contain_vcsrepo(target_path).with(
:source => source,
:ensure => :latest,
:owner => user,
:require => /rbenv::plugins #{user}/,
:path => ['/bin','/usr/bin','/usr/sbin']
)
end

it 'pulls the latest plugin changes from their git repos' do
should contain_exec("rbenv::plugin::update #{user} #{plugin_name}").with(
:command => 'git pull',
:user => user,
:cwd => target_path,
:require => /rbenv::plugin::checkout #{user} #{plugin_name}/,
:path => ['/bin','/usr/bin','/usr/sbin'],
:onlyif => 'git remote update; ' \
'if [ "$(git rev-parse @{0})" = "$(git rev-parse @{u})" ]; ' \
'then return 0; else return 1; fi ]'
)
end

Expand Down