Module: Capistrano::Git::SubmoduleStrategy

Includes:
DefaultStrategy
Defined in:
lib/capistrano/git-submodule-strategy.rb

Instance Method Summary collapse

Instance Method Details

#checkObject



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).split("\n").select{ |i| i.include?("refs/heads/#{fetch(:branch)}") }.empty?
    context.error "Branch `#{fetch(:branch)}` not found in repo `#{repo_url}`"
    return false
  end

  true
end

#cloneObject



26
27
28
# File 'lib/capistrano/git-submodule-strategy.rb', line 26

def clone
  git :clone, '--mirror', repo_url, repo_path
end

#releaseObject

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
# File 'lib/capistrano/git-submodule-strategy.rb', line 37

def release
  unless context.test(:test, '-e', release_path) && context.test(:ls, '-A', release_path)
    git :clone, '--depth=1', '--recursive', '-b', fetch(:branch), "file://#{repo_path}", release_path
    context.execute("find #{release_path} -name '.git*' | xargs -I {} rm -rfv {}")
  end
end

#testObject



8
9
10
# File 'lib/capistrano/git-submodule-strategy.rb', line 8

def test
  test! " [ -f #{repo_path}/HEAD ] "
end

#updateObject



30
31
32
# File 'lib/capistrano/git-submodule-strategy.rb', line 30

def update
  git :remote, :update
end