Skip to content

Instantly share code, notes, and snippets.

@ekho
Forked from bhaberer/submodule_strategy.rb
Last active August 29, 2015 13:58
Show Gist options
  • Save ekho/10113697 to your computer and use it in GitHub Desktop.
Save ekho/10113697 to your computer and use it in GitHub Desktop.
# Usage:
# 1. Drop this file into lib/capistrano/submodule_strategy.rb
# 2. Add the following to your Capfile:
# require './lib/capistrano/submodule_strategy'
# 3. Add the following to your config/deploy.rb
# set :git_strategy, SubmoduleStrategy
require 'capistrano/git'
module SubmoduleStrategy
# do all the things a normal capistrano git session would do
include Capistrano::Git::DefaultStrategy
def test
test! " [ -d #{repo_path}/.git ] "
end
def check
test! :git, :'ls-remote', repo_url
end
def clone
git :clone, '-b', fetch(:branch), '--recursive', repo_url, repo_path
end
def update
git :remote, :update
end
# put the working tree in a release-branch,
# make sure the submodules are up-to-date
# and copy everything to the release path
def release
git :checkout, fetch(:branch)
git :submodule, :update, '--init', '--recursive'
context.execute "rsync -ar --exclude=.git\* #{repo_path}/ #{release_path}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment