Skip to content

Instantly share code, notes, and snippets.

@seenmyfate
Created April 23, 2014 07:55
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seenmyfate/11206162 to your computer and use it in GitHub Desktop.
Save seenmyfate/11206162 to your computer and use it in GitHub Desktop.
Capistrano v3 custom Submodule Strategy example
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/scm'
require 'capistrano/git'
class Capistrano::Git < Capistrano::SCM
module SubmoduleStrategy
include DefaultStrategy
def release
context.execute :rm, '-rf', release_path
git :clone, '--branch', fetch(:branch),
'--recursive',
'--no-hardlinks',
repo_path, release_path
end
end
end
# ....other configuration
set :git_strategy, Capistrano::Git::SubmoduleStrategy
@brodock
Copy link

brodock commented May 26, 2014

From the v2 code:
https://github.com/capistrano/capistrano/blob/legacy-v2/lib/capistrano/recipes/deploy/scm/git.rb#L132

Should I need to do a "git submodule update --init --recursive" to have a submodule from a submodule cloned, or this code is enough?

Also, where should I override to disable the removing o .git folder?

@pyrmont
Copy link

pyrmont commented Sep 5, 2014

Thanks! Went hunting through a bunch of different solutions but this was the one that worked for me.

@chrishough
Copy link

This worked perfectly for me, thank you for posting.

@ranchhand6
Copy link

Perfect. Thanks!

@wmakley
Copy link

wmakley commented Dec 17, 2018

Trying to find some way to do this, but this doesn't work in Capistrano 3.11 since the DefaultStrategy constant is not found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment