Class: R10K::Environment::Git
- Inherits:
-
WithModules
- Object
- Base
- WithModules
- R10K::Environment::Git
- Includes:
- Logging, Util::Purgeable
- Defined in:
- lib/r10k/environment/git.rb
Overview
This class implements an environment based on a Git branch.
Constant Summary
Constants included from Logging
Instance Attribute Summary collapse
- #ref ⇒ Object readonly
- #remote ⇒ Object readonly
- #repo ⇒ Object readonly
Attributes inherited from WithModules
Attributes inherited from Base
#basedir, #dirname, #name, #path, #puppetfile, #puppetfile_name
Instance Method Summary collapse
-
#desired_contents ⇒ Array<String>
Returns an array of the full paths to all the content being managed.
-
#initialize(name, basedir, dirname, options = {}) ⇒ Git
constructor
Initialize the given Git environment.
-
#signature ⇒ String
Return a sting which uniquely identifies (per source) the current state of the environment.
- #status ⇒ Object
-
#sync ⇒ void
Clone or update the given Git environment.
Methods included from Util::Purgeable
#current_contents, #logger, #managed_directories, #pending_contents, #purge!, #stale_contents
Methods included from Logging
debug_formatter, default_formatter, default_outputter, #logger, #logger_name, parse_level
Methods inherited from WithModules
#accept, #add_module, #load_modules, #managed_directories, #modules, #purge_exclusions, #validate_no_module_conflicts
Methods inherited from Base
#accept, #generate_types!, #info, #modules, #purge_exclusions, #whitelist
Constructor Details
#initialize(name, basedir, dirname, options = {}) ⇒ Git
Initialize the given Git environment.
39 40 41 42 43 44 45 |
# File 'lib/r10k/environment/git.rb', line 39 def initialize(name, basedir, dirname, = {}) super @remote = [:remote] @ref = [:ref] @repo = R10K::Git::StatefulRepository.new(@remote, @basedir, @dirname) end |
Instance Attribute Details
#ref ⇒ Object (readonly)
23 24 25 |
# File 'lib/r10k/environment/git.rb', line 23 def ref @ref end |
#remote ⇒ Object (readonly)
19 20 21 |
# File 'lib/r10k/environment/git.rb', line 19 def remote @remote end |
#repo ⇒ Object (readonly)
28 29 30 |
# File 'lib/r10k/environment/git.rb', line 28 def repo @repo end |
Instance Method Details
#desired_contents ⇒ Array<String>
This implements a required method for the Purgeable mixin
Returns an array of the full paths to all the content being managed.
76 77 78 79 80 |
# File 'lib/r10k/environment/git.rb', line 76 def desired_contents desired = [File.join(@full_path, '.git')] desired += @repo.tracked_paths.map { |entry| File.join(@full_path, entry) } desired += super end |
#signature ⇒ String
Return a sting which uniquely identifies (per source) the current state of the environment.
67 68 69 |
# File 'lib/r10k/environment/git.rb', line 67 def signature @repo.head end |
#status ⇒ Object
58 59 60 |
# File 'lib/r10k/environment/git.rb', line 58 def status @repo.status(@ref) end |
#sync ⇒ void
This method returns an undefined value.
Clone or update the given Git environment.
If the environment is being created for the first time, it will automatically update all modules to ensure that the environment is complete.
54 55 56 |
# File 'lib/r10k/environment/git.rb', line 54 def sync @repo.sync(@ref) end |