Class: Capistrano::Distribution::Distributor::AbstractGit Abstract
- Defined in:
- lib/capistrano/distribution/distributor/abstract_git.rb
Overview
Subclass and override Capistrano::Distribution::Distributor::Abstract#check and Capistrano::Distribution::Distributor::Abstract#distribute to create a distributor that uses Git to distribute code from a Git repository.
An abstract distributor that operates on Git repositories.
Instance Attribute Summary collapse
-
#revision ⇒ Object
readonly
The identifier for a Git commit that will be distributed.
-
#subtree ⇒ Object
readonly
private
A subtree of the repository to distribute.
Attributes inherited from Abstract
#context, #repo_id, #target, #url
Instance Method Summary collapse
-
#initialize(context, url, revision, opts = {}) ⇒ AbstractGit
constructor
A new instance of AbstractGit.
-
#release ⇒ nil
private
Extracts the content of the commit at #revision from the local mirror of the repository to Capistrano::Distribution::Distributor::Abstract#release_path.
Methods inherited from Abstract
#check, #distribute, #release_path, #repo_path
Constructor Details
#initialize(context, url, revision, opts = {}) ⇒ AbstractGit
Returns a new instance of AbstractGit.
22 23 24 25 26 |
# File 'lib/capistrano/distribution/distributor/abstract_git.rb', line 22 def initialize(context, url, revision, opts = {}) super(context, url, opts) @revision = revision @subtree = opts[:subtree] end |
Instance Attribute Details
#revision ⇒ Object (readonly)
The identifier for a Git commit that will be distributed.
15 16 17 |
# File 'lib/capistrano/distribution/distributor/abstract_git.rb', line 15 def revision @revision end |
#subtree ⇒ Object (readonly, private)
A subtree of the repository to distribute.
32 33 34 |
# File 'lib/capistrano/distribution/distributor/abstract_git.rb', line 32 def subtree @subtree end |
Instance Method Details
#release ⇒ nil (private)
Extracts the content of the commit at #revision from the local mirror of the repository to Capistrano::Distribution::Distributor::Abstract#release_path.
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/capistrano/distribution/distributor/abstract_git.rb', line 39 def release context.execute 'mkdir', '-p', release_path if subtree path = subtree.slice %r#^/?(.*?)/?$#, 1 components = path.split('/').size context.execute :git, '--git-dir', repo_path, :archive, revision, path, "| tar -x --strip-components #{components} -f - -C", release_path else context.execute :git, '--git-dir', repo_path, :archive, revision, '| tar -x -f - -C', release_path end nil end |