class Capistrano::Distribution::Distributor::GitPull
Distributes by mirroring a remote Git repository on each target host and then extracting the content from a revision to the release location.
Public Instance Methods
Tests that the Git repository at {#url} is readable.
@return [Boolean] true
if the repository is readable; otherwise, false
# File lib/capistrano/distribution/distributor/git_pull.rb, line 15 def check context.test 'git', 'ls-remote', url end
Creates a mirror of the Git repository at {#url} if necessary, pulls updates into it, and finally extracts the revision to the release area. The Git repository is left in place in order to speed up future deployments by avoiding the need to pull all revision history again.
@return [nil]
@raise [exception] when distribution fails.
# File lib/capistrano/distribution/distributor/git_pull.rb, line 28 def distribute clone update release end
Private Instance Methods
Creates a mirror of the repository at {#url} in {#repo_path} if it does not already exist.
@return [nil]
@raise [exception] when mirror creation fails.
# File lib/capistrano/distribution/distributor/git_pull.rb, line 43 def clone if context.test '[', '!', '-e', repo_path.join('HEAD'), ']' context.execute 'rm', '-rf', repo_path context.execute 'git', 'clone', '--mirror', url, repo_path end nil end
Updates the Git mirror.
@return [nil]
@raise [exception] when updating the mirror fails.
# File lib/capistrano/distribution/distributor/git_pull.rb, line 57 def update context.execute 'git', '--git-dir', repo_path, 'remote', 'set-url', 'origin', url context.execute 'git', '--git-dir', repo_path, 'remote', 'update', '--prune' nil end