Class: Capistrano::Distribution::Distributor::GitPull
- Inherits:
-
AbstractGit
- Object
- Abstract
- AbstractGit
- Capistrano::Distribution::Distributor::GitPull
- Defined in:
- lib/capistrano/distribution/distributor/git_pull.rb
Overview
Distributes by mirroring a remote Git repository on each target host and then extracting the content from a revision to the release location.
Instance Attribute Summary
Attributes inherited from AbstractGit
Attributes inherited from Abstract
#context, #repo_id, #target, #url
Instance Method Summary collapse
-
#check ⇒ Boolean
Tests that the Git repository at Abstract#url is readable.
-
#clone ⇒ nil
private
Creates a mirror of the repository at Abstract#url in Abstract#repo_path if it does not already exist.
-
#distribute ⇒ nil
Creates a mirror of the Git repository at Abstract#url if necessary, pulls updates into it, and finally extracts the revision to the release area.
-
#update ⇒ nil
private
Updates the Git mirror.
Methods inherited from AbstractGit
Methods inherited from Abstract
#initialize, #release_path, #repo_path
Constructor Details
This class inherits a constructor from Capistrano::Distribution::Distributor::AbstractGit
Instance Method Details
#check ⇒ Boolean
Tests that the Git repository at Abstract#url is readable.
15 16 17 |
# File 'lib/capistrano/distribution/distributor/git_pull.rb', line 15 def check context.test 'git', 'ls-remote', url end |
#clone ⇒ nil (private)
Creates a mirror of the repository at Abstract#url in Abstract#repo_path if it does not already exist.
43 44 45 46 47 48 49 |
# 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 |
#distribute ⇒ nil
Creates a mirror of the Git repository at Abstract#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.
28 29 30 31 32 |
# File 'lib/capistrano/distribution/distributor/git_pull.rb', line 28 def distribute clone update release end |
#update ⇒ nil (private)
Updates the Git mirror.
57 58 59 60 61 62 |
# 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 |