diff options
author | Bruce Williams <bruce@codefluency.com> | 2010-03-15 11:16:22 -0700 |
---|---|---|
committer | Bruce Williams <bruce@codefluency.com> | 2010-03-15 11:16:22 -0700 |
commit | 4b8e7074e62900ed796cc05bb67a7561f40f899a (patch) | |
tree | 2e0e801b21605ca74d18317adff0930088101597 /lib | |
parent | 52e078444a12d47530a4299d0e9d60b86066c76e (diff) |
ensure = latest to support reference tracking.\n\nWorking with tags, more work needed for branches (at least with git)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/provider/vcsrepo/bzr.rb | 1 | ||||
-rw-r--r-- | lib/puppet/provider/vcsrepo/cvs.rb | 2 | ||||
-rw-r--r-- | lib/puppet/provider/vcsrepo/git.rb | 18 | ||||
-rw-r--r-- | lib/puppet/provider/vcsrepo/hg.rb | 1 | ||||
-rw-r--r-- | lib/puppet/provider/vcsrepo/svn.rb | 2 | ||||
-rw-r--r-- | lib/puppet/type/vcsrepo.rb | 17 |
6 files changed, 35 insertions, 6 deletions
diff --git a/lib/puppet/provider/vcsrepo/bzr.rb b/lib/puppet/provider/vcsrepo/bzr.rb index a6e12cd..a060562 100644 --- a/lib/puppet/provider/vcsrepo/bzr.rb +++ b/lib/puppet/provider/vcsrepo/bzr.rb @@ -5,6 +5,7 @@ Puppet::Type.type(:vcsrepo).provide(:bzr, :parent => Puppet::Provider::Vcsrepo) commands :bzr => 'bzr' defaultfor :bzr => :exists + has_features :reference_tracking def create if !@resource.value(:source) diff --git a/lib/puppet/provider/vcsrepo/cvs.rb b/lib/puppet/provider/vcsrepo/cvs.rb index 1cedc8b..e82c23a 100644 --- a/lib/puppet/provider/vcsrepo/cvs.rb +++ b/lib/puppet/provider/vcsrepo/cvs.rb @@ -5,7 +5,7 @@ Puppet::Type.type(:vcsrepo).provide(:cvs, :parent => Puppet::Provider::Vcsrepo) commands :cvs => 'cvs' defaultfor :cvs => :exists - has_features :gzip_compression + has_features :gzip_compression, :reference_tracking def create if !@resource.value(:source) diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 274f25b..ba5065e 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -5,7 +5,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) commands :git => 'git' defaultfor :git => :exists - has_features :bare_repositories + has_features :bare_repositories, :reference_tracking def create if !@resource.value(:source) @@ -37,7 +37,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) end def revision=(desired) - fetch + pull reset(desired) end @@ -48,6 +48,16 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) def working_copy_exists? File.directory?(File.join(@resource.value(:path), '.git')) end + + def exists? + working_copy_exists? || bare_exists? + end + + def update_references + at_path do + git('fetch', '--tags', 'origin') + end + end private @@ -68,9 +78,9 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) git(*args) end - def fetch + def pull at_path do - git('fetch', 'origin') + git('pull', 'origin') end end diff --git a/lib/puppet/provider/vcsrepo/hg.rb b/lib/puppet/provider/vcsrepo/hg.rb index 928049f..df8b4f0 100644 --- a/lib/puppet/provider/vcsrepo/hg.rb +++ b/lib/puppet/provider/vcsrepo/hg.rb @@ -5,6 +5,7 @@ Puppet::Type.type(:vcsrepo).provide(:hg, :parent => Puppet::Provider::Vcsrepo) d commands :hg => 'hg' defaultfor :hg => :exists + has_features :reference_tracking def create if !@resource.value(:source) diff --git a/lib/puppet/provider/vcsrepo/svn.rb b/lib/puppet/provider/vcsrepo/svn.rb index 7cdd157..5fa586d 100644 --- a/lib/puppet/provider/vcsrepo/svn.rb +++ b/lib/puppet/provider/vcsrepo/svn.rb @@ -7,7 +7,7 @@ Puppet::Type.type(:vcsrepo).provide(:svn, :parent => Puppet::Provider::Vcsrepo) :svnadmin => 'svnadmin' defaultfor :svn => :exists - has_features :filesystem_types + has_features :filesystem_types, :reference_tracking def create if !@resource.value(:source) diff --git a/lib/puppet/type/vcsrepo.rb b/lib/puppet/type/vcsrepo.rb index 69c7f74..137f8cd 100644 --- a/lib/puppet/type/vcsrepo.rb +++ b/lib/puppet/type/vcsrepo.rb @@ -14,6 +14,10 @@ Puppet::Type.newtype(:vcsrepo) do feature :filesystem_types, "The provider supports different filesystem types" + feature :reference_tracking, + "The provider supports tracking revision references that can change + over time (eg, some VCS tags and branch names)" + ensurable do newvalue :present do @@ -28,6 +32,19 @@ Puppet::Type.newtype(:vcsrepo) do provider.destroy end + newvalue :latest, :required_features => [:reference_tracking] do + if provider.exists? + if provider.respond_to?(:update_references) + provider.update_references + end + reference = resource.value(:revision) || provider.revision + notice "Updating to latest '#{reference}' revision" + provider.revision = reference + else + provider.create + end + end + def retrieve prov = @resource.provider if prov |