summaryrefslogtreecommitdiff
path: root/lib/puppet/provider
diff options
context:
space:
mode:
authorJesusaurus <jesusaurus@inbox.com>2012-05-12 20:42:05 -0700
committerJesusaurus <jesusaurus@inbox.com>2012-05-13 01:55:47 -0700
commitdce22cfd2d2f4c237df597cf6206d5c0d1aebc65 (patch)
treeb8e05b35c9ff8110db5fbbae7d5cb7d5070f2276 /lib/puppet/provider
parent462b1d69bbc5d6c171dcee02a3d88d304acd630e (diff)
downloadpuppet-vcsrepo-dce22cfd2d2f4c237df597cf6206d5c0d1aebc65.tar.gz
puppet-vcsrepo-dce22cfd2d2f4c237df597cf6206d5c0d1aebc65.tar.bz2
Add the ability to specify a git remote
Rather than fill the git provider with hard-coded references to origin, it would be better to abstract out which remote the resource is fetching from. But since this is only relevant to decentralized version-control systems, a multiple_remotes feature was added for the parameter to depend on. So far this is only implemented for git remotes, but it could be implemented for other VCSs as well.
Diffstat (limited to 'lib/puppet/provider')
-rw-r--r--lib/puppet/provider/vcsrepo/git.rb24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb
index 7fa755d..5febce2 100644
--- a/lib/puppet/provider/vcsrepo/git.rb
+++ b/lib/puppet/provider/vcsrepo/git.rb
@@ -6,7 +6,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
##TODO modify the commands below so that the su - is included
optional_commands :git => 'git'
defaultfor :git => :exists
- has_features :bare_repositories, :reference_tracking, :ssh_identity
+ has_features :bare_repositories, :reference_tracking, :ssh_identity, :multiple_remotes
def create
if !@resource.value(:source)
@@ -40,11 +40,11 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
def latest
branch = on_branch?
if branch == 'master'
- return get_revision('origin/HEAD')
+ return get_revision("#{@resource.value(:remote)}/HEAD")
elsif branch == '(no branch)'
return get_revision('HEAD')
else
- return get_revision('origin/%s' % branch)
+ return get_revision("#{@resource.value(:remote)}/%s" % branch)
end
end
@@ -73,7 +73,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
# authoritative.
# might be worthwhile to have an allow_local_changes param to decide
# whether to reset or pull when we're ensuring latest.
- at_path { git_with_identity('reset', '--hard', "origin/#{desired}") }
+ at_path { git_with_identity('reset', '--hard', "#{@resource.value(:remote)}/#{desired}") }
end
if @resource.value(:ensure) != :bare
update_submodules
@@ -95,7 +95,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
def update_references
at_path do
- git_with_identity('fetch', '--tags', 'origin')
+ git_with_identity('fetch', '--tags', @resource.value(:remote))
update_owner_and_excludes
end
end
@@ -190,7 +190,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
def checkout(revision = @resource.value(:revision))
if !local_branch_revision? && remote_branch_revision?
- at_path { git_with_identity('checkout', '-b', revision, '--track', "origin/#{revision}") }
+ at_path { git_with_identity('checkout', '-b', revision, '--track', "#{@resource.value(:remote)}/#{revision}") }
else
at_path { git_with_identity('checkout', '--force', revision) }
end
@@ -212,9 +212,9 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
end
def remote_branch_revision?(revision = @resource.value(:revision))
- # git < 1.6 returns 'origin/#{revision}'
- # git 1.6+ returns 'remotes/origin/#{revision}'
- branch = at_path { branches.grep /(remotes\/)?origin\/#{revision}/ }
+ # git < 1.6 returns '#{@resource.value(:remote)}/#{revision}'
+ # git 1.6+ returns 'remotes/#{@resource.value(:remote)}/#{revision}'
+ branch = at_path { branches.grep /(remotes\/)?#{@resource.value(:remote)}\/#{revision}/ }
if branch.length > 0
return branch
end
@@ -249,15 +249,15 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
create
end
at_path do
- git_with_identity('fetch', 'origin')
- git_with_identity('fetch', '--tags', 'origin')
+ git_with_identity('fetch', @resource.value(:remote))
+ git_with_identity('fetch', '--tags', @resource.value(:remote))
end
current = at_path { git_with_identity('rev-parse', rev).strip }
if @resource.value(:revision)
if local_branch_revision?
canonical = at_path { git_with_identity('rev-parse', @resource.value(:revision)).strip }
elsif remote_branch_revision?
- canonical = at_path { git_with_identity('rev-parse', 'origin/' + @resource.value(:revision)).strip }
+ canonical = at_path { git_with_identity('rev-parse', "#{@resource.value(:remote)}/" + @resource.value(:revision)).strip }
end
current = @resource.value(:revision) if current == canonical
end