From 8efa139dda9a0a81d3d0899d534a0878ad4f95d0 Mon Sep 17 00:00:00 2001 From: Cha Jae Mun Date: Fri, 13 Apr 2018 18:42:33 +0900 Subject: [PATCH] Fix `git submodule sync` change repo/modules//config `submodule sync` has not affect repo/modules//config it only affect on `repo/config`. should `submodule update` before `submodule sync` to update repo/modules//config even it failed --- lib/capistrano/scm/git-with-submodules.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/capistrano/scm/git-with-submodules.rb b/lib/capistrano/scm/git-with-submodules.rb index ad1f129..4376d56 100644 --- a/lib/capistrano/scm/git-with-submodules.rb +++ b/lib/capistrano/scm/git-with-submodules.rb @@ -28,8 +28,16 @@ def define_tasks quiet = Rake.application.options.trace ? '' : '--quiet' execute :git, :reset, '--mixed', quiet, fetch(:branch), '--' - execute :git, :submodule, 'sync', '--recursive', quiet - execute :git, :submodule, 'update', '--init', '--checkout', '--recursive', quiet + update_submodule = proc do + execute :git, :submodule, 'update', + '--init', '--checkout', '--recursive', quiet + end + begin + update_submodule.call + rescue SSHKit::Command::Failed + execute :git, :submodule, 'sync', '--recursive', quiet + update_submodule.call + end execute :find, release_path, "-name '.git'", "|", "xargs -I {} rm -rf#{verbose} '{}'" execute :rm, "-f#{verbose}", temp_index_file_path.to_s end if test :test, '-f', release_path.join('.gitmodules')