9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/capistrano/scm/git-with-submodules.rb', line 9
def define_tasks
namespace :git do
namespace :submodules do
desc "Adds configured submodules recursively to release"
task create_release: :'git:update' do
temp_index_file_path = release_path.join("TEMP_INDEX_#{fetch(:release_timestamp)}")
on release_roles :all do
with fetch(:git_environmental_variables).merge(
'GIT_DIR' => repo_path.to_s,
'GIT_WORK_TREE' => release_path.to_s,
'GIT_INDEX_FILE' => temp_index_file_path.to_s
) do
within release_path do
verbose = Rake.application.options.trace ? 'v' : ''
quiet = Rake.application.options.trace ? '' : '--quiet'
execute :git, :reset, '--mixed', quiet, fetch(:branch), '--'
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')
end
end
end
end
end
end
|