Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/reductivelabs/puppet-vcsrepo
Browse files Browse the repository at this point in the history
  • Loading branch information
jamtur01 committed Sep 13, 2010
2 parents e572002 + a71777b commit f9f8a80
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 22 deletions.
34 changes: 24 additions & 10 deletions lib/puppet/provider/vcsrepo/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,19 @@ def destroy
FileUtils.rm_rf(@resource.value(:path))
end

def revision
if !working_copy_exists?
create
def latest?
at_path do
return self.revision == self.latest
end
end

current = at_path { git('rev-parse', 'HEAD') }
canonical = at_path { git('rev-parse', @resource.value(:revision)) }
if current == canonical
@resource.value(:revision)
else
current
end
def latest
fetch
return get_revision('origin/HEAD')
end

def revision
return get_revision('HEAD')
end

def revision=(desired)
Expand Down Expand Up @@ -219,4 +220,17 @@ def branches
at_path { git('branch', '-a') }.gsub('*', ' ').split(/\n/).map { |line| line.strip }
end

def get_revision(rev)
if !working_copy_exists?
create
end

current = at_path { git('rev-parse', rev).strip }
if @resource.value(:revision)
canonical = at_path { git('rev-parse', @resource.value(:revision)).strip }
current = @resource.value(:revision) if current == canonical
end

return current
end
end
20 changes: 8 additions & 12 deletions lib/puppet/type/vcsrepo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ def insync?(is)
when :present
return true unless [:absent, :purged, :held].include?(is)
when :latest
if provider.latest?
if is == :latest
return true
else
self.debug "%s repo revision is %s, latest is %s" %
[@resource.name, provider.revision, provider.latest]
return false
end
end
end
end

Expand Down Expand Up @@ -70,16 +70,12 @@ def insync?(is)
def retrieve
prov = @resource.provider
if prov
if prov.class.feature?(:bare_repositories)
if prov.working_copy_exists?
:present
elsif prov.bare_exists?
:bare
else
:absent
end
if prov.working_copy_exists?
prov.latest? ? :latest : :present
elsif prov.class.feature?(:bare_repositories) and prov.bare_exists?
:bare
else
prov.exists? ? :present : :absent
:absent
end
else
raise Puppet::Error, "Could not find provider"
Expand Down Expand Up @@ -121,4 +117,4 @@ def retrieve
end
end

end
end

0 comments on commit f9f8a80

Please sign in to comment.