Module: Capistrano::Git::SubmoduleStrategy
- Includes:
- DefaultStrategy
- Defined in:
- lib/capistrano/git-submodule-strategy.rb
Instance Method Summary collapse
- #check ⇒ Object
- #clone ⇒ Object
-
#release ⇒ Object
put the working tree in a release-branch, make sure the submodules are up-to-date and copy everything to the release path.
- #test ⇒ Object
- #update ⇒ Object
Instance Method Details
#check ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/capistrano/git-submodule-strategy.rb', line 12 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 |
#clone ⇒ Object
26 27 28 |
# File 'lib/capistrano/git-submodule-strategy.rb', line 26 def clone git :clone, '--mirror', repo_url, repo_path end |
#release ⇒ Object
put the working tree in a release-branch, make sure the submodules are up-to-date and copy everything to the release path
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/capistrano/git-submodule-strategy.rb', line 37 def release return if context.test(:test, '-e', release_path) && context.test("ls -A #{release_path} | read linevar") git_version = context.capture(:git, '--version').strip.match('^git version (\d+(?:\.\d+)+)$') if git_version.nil? || git_version[1] < '2.3.0' git :clone, (fetch(:git_keep_meta, false) ? '' : '--depth=1'), '-b', fetch(:branch), "file://#{repo_path}", release_path context.within_only release_path do git :remote, 'set-url', 'origin', repo_url end else git :clone, "--reference #{repo_path}", '--dissociate', (fetch(:git_keep_meta, false) ? '' : '--depth=1'), '-b', fetch(:branch), repo_url, release_path end context.within_only release_path do git :submodule, 'update', '--init', '--recursive' end unless fetch(:git_keep_meta, false) verbose = Rake.application..trace ? 'v' : '' context.execute("find #{release_path} -name '.git*' | xargs -I {} rm -rf#{verbose} '{}'") end end |
#test ⇒ Object
8 9 10 |
# File 'lib/capistrano/git-submodule-strategy.rb', line 8 def test test! " [ -f #{repo_path}/HEAD ] " end |
#update ⇒ Object
30 31 32 |
# File 'lib/capistrano/git-submodule-strategy.rb', line 30 def update git :remote, :update end |