Class: R10K::Git::WorkingDir
- Inherits:
-
Repository
- Object
- Repository
- R10K::Git::WorkingDir
- Extended by:
- Forwardable
- Includes:
- Logging
- Defined in:
- lib/r10k/git/working_dir.rb
Constant Summary
Constants included from Logging
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
-
#ref ⇒ Object
readonly
Returns the value of attribute ref.
Attributes inherited from Repository
Instance Method Summary collapse
-
#cloned? ⇒ true, false
Determine if repo has been cloned into a specific dir.
-
#initialize(ref, remote, basedir, dirname = nil) ⇒ WorkingDir
constructor
Instantiates a new git synchro and optionally prepares for caching.
-
#sync ⇒ Object
Synchronize the local git repository.
Methods included from Logging
formatter, included, level, level=, levels, #logger, #logger_name, outputter, parse_level
Methods inherited from Repository
Methods included from Execution
Constructor Details
#initialize(ref, remote, basedir, dirname = nil) ⇒ WorkingDir
Instantiates a new git synchro and optionally prepares for caching
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/r10k/git/working_dir.rb', line 32 def initialize(ref, remote, basedir, dirname = nil) @ref = ref @remote = remote @basedir = basedir @dirname = dirname || ref @full_path = File.join(@basedir, @dirname) @cache = R10K::Git::Cache.generate(@remote) end |
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
20 21 22 |
# File 'lib/r10k/git/working_dir.rb', line 20 def cache @cache end |
#ref ⇒ Object (readonly)
Returns the value of attribute ref.
24 25 26 |
# File 'lib/r10k/git/working_dir.rb', line 24 def ref @ref end |
Instance Method Details
#cloned? ⇒ true, false
Determine if repo has been cloned into a specific dir
59 60 61 |
# File 'lib/r10k/git/working_dir.rb', line 59 def cloned? File.directory? git_dir end |
#sync ⇒ Object
Synchronize the local git repository.
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/r10k/git/working_dir.rb', line 44 def sync # TODO stop forcing a sync every time. @cache.sync if cloned? fetch else clone end reset end |