From 05c707cf625a90a6b78653dae75e453c308f881c Mon Sep 17 00:00:00 2001 From: Ken Miller Date: Fri, 22 Apr 2011 15:26:53 -0700 Subject: [PATCH] improving behavior with git submodules --- lib/capistrano/recipes/deploy/scm/git.rb | 4 ++-- test/deploy/scm/git_test.rb | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/capistrano/recipes/deploy/scm/git.rb b/lib/capistrano/recipes/deploy/scm/git.rb index 8d7468c1b..6839a03dd 100644 --- a/lib/capistrano/recipes/deploy/scm/git.rb +++ b/lib/capistrano/recipes/deploy/scm/git.rb @@ -148,7 +148,7 @@ def checkout(revision, destination) if variable(:git_enable_submodules) execute << "#{git} submodule #{verbose} init" execute << "#{git} submodule #{verbose} sync" - execute << "#{git} submodule #{verbose} update --recursive" + execute << "#{git} submodule #{verbose} update --init --recursive" end execute.join(" && ") @@ -187,7 +187,7 @@ def sync(revision, destination) execute << "#{git} submodule #{verbose} init" execute << "for mod in `#{git} submodule status | awk '{ print $2 }'`; do #{git} config -f .git/config submodule.${mod}.url `#{git} config -f .gitmodules --get submodule.${mod}.url` && echo Synced $mod; done" execute << "#{git} submodule #{verbose} sync" - execute << "#{git} submodule #{verbose} update" + execute << "#{git} submodule #{verbose} update --init --recursive" end # Make sure there's nothing else lying around in the repository (for diff --git a/test/deploy/scm/git_test.rb b/test/deploy/scm/git_test.rb index 0e31af357..a468373d4 100644 --- a/test/deploy/scm/git_test.rb +++ b/test/deploy/scm/git_test.rb @@ -40,7 +40,7 @@ def test_checkout # with submodules @config[:git_enable_submodules] = true - assert_equal "#{git} clone -q git@somehost.com:project.git /var/www && cd /var/www && #{git} checkout -q -b deploy #{rev} && #{git} submodule -q init && #{git} submodule -q sync && #{git} submodule -q update --recursive", @source.checkout(rev, dest).gsub(/\s+/, ' ') + assert_equal "#{git} clone -q git@somehost.com:project.git /var/www && cd /var/www && #{git} checkout -q -b deploy #{rev} && #{git} submodule -q init && #{git} submodule -q sync && #{git} submodule -q update --init --recursive", @source.checkout(rev, dest).gsub(/\s+/, ' ') end def test_checkout_with_verbose_should_not_use_q_switch @@ -101,7 +101,7 @@ def test_sync # with submodules @config[:git_enable_submodules] = true - assert_equal "cd #{dest} && #{git} fetch -q origin && #{git} reset -q --hard #{rev} && #{git} submodule -q init && for mod in `#{git} submodule status | awk '{ print $2 }'`; do #{git} config -f .git/config submodule.${mod}.url `#{git} config -f .gitmodules --get submodule.${mod}.url` && echo Synced $mod; done && #{git} submodule -q sync && #{git} submodule -q update && #{git} clean -q -d -x -f", @source.sync(rev, dest) + assert_equal "cd #{dest} && #{git} fetch -q origin && #{git} reset -q --hard #{rev} && #{git} submodule -q init && for mod in `#{git} submodule status | awk '{ print $2 }'`; do #{git} config -f .git/config submodule.${mod}.url `#{git} config -f .gitmodules --get submodule.${mod}.url` && echo Synced $mod; done && #{git} submodule -q sync && #{git} submodule -q update --init --recursive && #{git} clean -q -d -x -f", @source.sync(rev, dest) end def test_sync_with_remote @@ -138,7 +138,7 @@ def test_remote_clone_with_submodules @config[:git_enable_submodules] = true dest = "/var/www" rev = 'c2d9e79' - assert_equal "git clone -q -o username git@somehost.com:project.git /var/www && cd /var/www && git checkout -q -b deploy #{rev} && git submodule -q init && git submodule -q sync && git submodule -q update --recursive", @source.checkout(rev, dest) + assert_equal "git clone -q -o username git@somehost.com:project.git /var/www && cd /var/www && git checkout -q -b deploy #{rev} && git submodule -q init && git submodule -q sync && git submodule -q update --init --recursive", @source.checkout(rev, dest) end # Tests from base_test.rb, makin' sure we didn't break anything up there!