Class: Capistrano::Distribution::Distributor::GitPush
- Inherits:
-
AbstractGit
- Object
- Abstract
- AbstractGit
- Capistrano::Distribution::Distributor::GitPush
- Defined in:
- lib/capistrano/distribution/distributor/git_push.rb
Overview
Distributes by pushing a local Git repository into a clone 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 ⇒ true
Always returns
true
because this distributor does not pull content but rather relies on the distribute step to push the content up. -
#distribute ⇒ nil
Prepares a Git repository if necessary, pushes the selected revision to the Git repository, and finally extracts the revision to the release area.
-
#init ⇒ nil
private
Initializes a bare Git repository in Abstract#repo_path if a repository does not already exist there.
-
#push ⇒ Object
private
Pushes AbstractGit#revision and all its history to the Git repository within Abstract#repo_path.
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 ⇒ true
Always returns true
because this distributor does not pull content but rather relies on the distribute step to push the content up.
16 17 18 |
# File 'lib/capistrano/distribution/distributor/git_push.rb', line 16 def check true end |
#distribute ⇒ nil
Prepares a Git repository if necessary, pushes the selected revision to the Git repository, 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 upload all revision history again.
29 30 31 32 33 34 |
# File 'lib/capistrano/distribution/distributor/git_push.rb', line 29 def distribute init push release nil end |
#init ⇒ nil (private)
Initializes a bare Git repository in Abstract#repo_path if a repository does not already exist there.
45 46 47 48 49 50 51 |
# File 'lib/capistrano/distribution/distributor/git_push.rb', line 45 def init if context.test '[', '!', '-e', repo_path.join('HEAD'), ']' context.execute 'rm', '-rf', repo_path context.execute 'git', 'init', '--bare', repo_path end nil end |
#push ⇒ Object (private)
Pushes AbstractGit#revision and all its history to the Git repository within Abstract#repo_path.
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/capistrano/distribution/distributor/git_push.rb', line 58 def push user = context.host.user hostname = context.host.hostname repo_path = self.repo_path revision = self.revision context.run_locally do execute 'git', 'push', "ssh://#{user}@#{hostname}/#{repo_path}", "+#{revision}:refs/tags/deploy" end end |