Sha256: ff30bba6dce429979917985dd060d2a8cd5bd185c2f0bf5fa5c84a92314286f9
Contents?: true
Size: 1.86 KB
Versions: 1
Compression:
Stored size: 1.86 KB
Contents
require 'capistrano/git' class Capistrano::Git module SubmoduleStrategy # do all the things a normal capistrano git session would do include Capistrano::Git::DefaultStrategy def test test! " [ -f #{repo_path}/HEAD ] " end def check unless test!(:git, :'ls-remote', repo_url) context.error "Repo `#{repo_url}` does not exists" return false end if context.capture(:git, :'ls-remote', repo_url, fetch(:branch)).empty? context.error "Branch `#{fetch(:branch)}` not found in repo `#{repo_url}`" return false end true end def clone git :clone, '--mirror', 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 unless context.test(:test, '-e', release_path) && context.test("ls -A #{release_path} | read linevar") git :clone, (fetch(:git_keep_meta, false) ? '' : '--depth=1'), '-b', fetch(:branch), "file://#{repo_path}", release_path context.within_only release_path do git :submodule, 'update', '--init', '--recursive' end if fetch(:git_keep_meta, false) context.within_only release_path do git :remote, 'set-url', 'origin', repo_url end else verbose = Rake.application.options.trace ? 'v' : '' context.execute("find #{release_path} -name '.git*' | xargs -I {} rm -rf#{verbose} '{}'") end end end end end # shit hack to execute command only in specified directory module SSHKit module Backend class Abstract def within_only(directory, &block) pwd = @pwd @pwd = [] within directory, &block ensure @pwd = pwd end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
capistrano-git-submodule-strategy-0.1.19 | lib/capistrano/git-submodule-strategy.rb |