Add submodule support to git provider
This commit is contained in:
parent
3439ff1939
commit
dc64158c8c
@ -19,6 +19,9 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
|
|||||||
reset(@resource.value(:revision))
|
reset(@resource.value(:revision))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if @resource.value(:ensure) != :bare
|
||||||
|
update_submodules
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -39,6 +42,9 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
|
|||||||
def revision=(desired)
|
def revision=(desired)
|
||||||
fetch
|
fetch
|
||||||
reset(desired)
|
reset(desired)
|
||||||
|
unless @resource.value(:ensure) == :bare
|
||||||
|
update_submodules
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def bare_exists?
|
def bare_exists?
|
||||||
@ -150,4 +156,11 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update_submodules
|
||||||
|
at_path do
|
||||||
|
git('submodule', 'init')
|
||||||
|
git('submodule', 'update')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -10,13 +10,18 @@ describe_provider :vcsrepo, :git, :resource => {:path => '/tmp/vcsrepo'} do
|
|||||||
provider.expects('git').with('clone', resource.value(:source), resource.value(:path))
|
provider.expects('git').with('clone', resource.value(:source), resource.value(:path))
|
||||||
expects_chdir
|
expects_chdir
|
||||||
provider.expects('git').with('reset', '--hard', resource.value(:revision))
|
provider.expects('git').with('reset', '--hard', resource.value(:revision))
|
||||||
|
provider.expects(:git).with('submodule', 'init')
|
||||||
|
provider.expects(:git).with('submodule', 'update')
|
||||||
provider.create
|
provider.create
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
resource_without :revision do
|
resource_without :revision do
|
||||||
it "should just execute 'git clone'" do
|
it "should execute 'git clone' and submodule commands" do
|
||||||
provider.expects(:git).with('clone', resource.value(:source), resource.value(:path))
|
provider.expects(:git).with('clone', resource.value(:source), resource.value(:path))
|
||||||
|
expects_chdir
|
||||||
|
provider.expects(:git).with('submodule', 'init')
|
||||||
|
provider.expects(:git).with('submodule', 'update')
|
||||||
provider.create
|
provider.create
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -25,15 +30,15 @@ describe_provider :vcsrepo, :git, :resource => {:path => '/tmp/vcsrepo'} do
|
|||||||
resource_with :ensure => :bare do
|
resource_with :ensure => :bare do
|
||||||
resource_with :revision do
|
resource_with :revision do
|
||||||
it "should just execute 'git clone --bare'" do
|
it "should just execute 'git clone --bare'" do
|
||||||
subject.expects(:git).with('clone', '--bare', resource.value(:source), resource.value(:path))
|
provider.expects(:git).with('clone', '--bare', resource.value(:source), resource.value(:path))
|
||||||
subject.create
|
provider.create
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
resource_without :revision do
|
resource_without :revision do
|
||||||
it "should just execute 'git clone --bare'" do
|
it "should just execute 'git clone --bare'" do
|
||||||
subject.expects(:git).with('clone', '--bare', resource.value(:source), resource.value(:path))
|
provider.expects(:git).with('clone', '--bare', resource.value(:source), resource.value(:path))
|
||||||
subject.create
|
provider.create
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -134,8 +139,10 @@ describe_provider :vcsrepo, :git, :resource => {:path => '/tmp/vcsrepo'} do
|
|||||||
context "setting the revision property" do
|
context "setting the revision property" do
|
||||||
it "should use 'git fetch' and 'git reset'" do
|
it "should use 'git fetch' and 'git reset'" do
|
||||||
expects_chdir
|
expects_chdir
|
||||||
provider.expects('git').with('fetch', 'origin')
|
provider.expects(:git).with('fetch', 'origin')
|
||||||
provider.expects('git').with('reset', '--hard', 'carcar')
|
provider.expects(:git).with('reset', '--hard', 'carcar')
|
||||||
|
provider.expects(:git).with('submodule', 'init')
|
||||||
|
provider.expects(:git).with('submodule', 'update')
|
||||||
provider.revision = 'carcar'
|
provider.revision = 'carcar'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -143,7 +150,7 @@ describe_provider :vcsrepo, :git, :resource => {:path => '/tmp/vcsrepo'} do
|
|||||||
context "updating references" do
|
context "updating references" do
|
||||||
it "should use 'git fetch --tags'" do
|
it "should use 'git fetch --tags'" do
|
||||||
expects_chdir
|
expects_chdir
|
||||||
provider.expects('git').with('fetch', '--tags', 'origin')
|
provider.expects(:git).with('fetch', '--tags', 'origin')
|
||||||
provider.update_references
|
provider.update_references
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user