summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/provider/vcsrepo/bzr.rb20
-rw-r--r--lib/puppet/provider/vcsrepo/git.rb20
2 files changed, 36 insertions, 4 deletions
diff --git a/lib/puppet/provider/vcsrepo/bzr.rb b/lib/puppet/provider/vcsrepo/bzr.rb
index 6169929..fff25b3 100644
--- a/lib/puppet/provider/vcsrepo/bzr.rb
+++ b/lib/puppet/provider/vcsrepo/bzr.rb
@@ -45,7 +45,25 @@ Puppet::Type.type(:vcsrepo).provide(:bzr, :parent => Puppet::Provider::Vcsrepo)
end
def revision=(desired)
- bzr('update', '-r', desired, @resource.value(:path))
+ at_path do
+ begin
+ bzr('update', '-r', desired)
+ rescue Puppet::ExecutionFailure
+ bzr('update', '-r', desired, ':parent')
+ end
+ end
+ end
+
+ def latest
+ at_path do
+ bzr('version-info', ':parent')[/^revision-id:\s+(\S+)/, 1]
+ end
+ end
+
+ def latest?
+ at_path do
+ return self.revision == self.latest
+ end
end
private
diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb
index 9254243..76fa315 100644
--- a/lib/puppet/provider/vcsrepo/git.rb
+++ b/lib/puppet/provider/vcsrepo/git.rb
@@ -54,7 +54,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
return current unless @resource.value(:revision)
if tag_revision?(@resource.value(:revision))
- canonical = at_path { git_with_identity('show', @resource.value(:revision)).scan(/commit (.*)/).to_s }
+ canonical = at_path { git_with_identity('show', @resource.value(:revision)).scan(/^commit (.*)/).to_s }
else
canonical = at_path { git_with_identity('rev-parse', @resource.value(:revision)).chomp }
end
@@ -93,8 +93,18 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
working_copy_exists? || bare_exists?
end
+ def update_remote_origin_url
+ current = git_with_identity('config', 'remote.origin.url')
+ unless @resource.value(:source).nil?
+ if current.nil? or current.strip != @resource.value(:source)
+ git_with_identity('config', 'remote.origin.url', @resource.value(:source))
+ end
+ end
+ end
+
def update_references
at_path do
+ update_remote_origin_url
git_with_identity('fetch', @resource.value(:remote))
git_with_identity('fetch', '--tags', @resource.value(:remote))
update_owner_and_excludes
@@ -115,7 +125,9 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
end
if !File.exist?(File.join(@resource.value(:path), '.git'))
args.push(source, path)
- git_with_identity(*args)
+ Dir.chdir("/") do
+ git_with_identity(*args)
+ end
else
notice "Repo has already been cloned"
end
@@ -141,6 +153,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
else
# normal init
FileUtils.mkdir(@resource.value(:path))
+ FileUtils.chown(@resource.value(:user), nil, @resource.value(:path)) if @resource.value(:user)
args = ['init']
if @resource.value(:ensure) == :bare
args << '--bare'
@@ -250,6 +263,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
create
end
at_path do
+ update_remote_origin_url
git_with_identity('fetch', @resource.value(:remote))
git_with_identity('fetch', '--tags', @resource.value(:remote))
end
@@ -279,7 +293,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
if @resource.value(:identity)
Tempfile.open('git-helper') do |f|
f.puts '#!/bin/sh'
- f.puts "exec ssh -oStrictHostKeyChecking=no -oPasswordAuthentication=no -oKbdInteractiveAuthentication=no -oChallengeResponseAuthentication=no -i #{@resource.value(:identity)} $*"
+ f.puts "exec ssh -oStrictHostKeyChecking=no -oPasswordAuthentication=no -oKbdInteractiveAuthentication=no -oChallengeResponseAuthentication=no -oConnectTimeout=120 -i #{@resource.value(:identity)} $*"
f.close
FileUtils.chmod(0755, f.path)