Class: R10K::Git::ShellGit::ThinRepository
- Inherits:
-
WorkingRepository
- Object
- BaseRepository
- WorkingRepository
- R10K::Git::ShellGit::ThinRepository
- Defined in:
- lib/r10k/git/shellgit/thin_repository.rb
Overview
Manage a Git working repository backed with cached bare repositories. Instead of duplicating all objects for new clones and updates, this uses Git alternate object databases to reuse objects from an existing repository, making new clones very lightweight.
Constant Summary
Constants included from Logging
Instance Attribute Summary
Attributes inherited from WorkingRepository
Instance Method Summary collapse
-
#cache ⇒ String
The origin remote URL.
-
#clone(remote, opts = {}) ⇒ void
Clone this git repository.
-
#fetch(remote = 'cache') ⇒ Object
Fetch refs from the backing bare Git repository.
-
#initialize(basedir, dirname) ⇒ ThinRepository
constructor
A new instance of ThinRepository.
Methods inherited from WorkingRepository
#alternates, #checkout, #exist?, #git_dir, #head, #origin
Methods inherited from BaseRepository
#branches, #git_dir, #ref_type, #resolve, #tags
Methods included from Logging
debug_formatter, default_formatter, default_outputter, #logger, #logger_name, parse_level
Constructor Details
#initialize(basedir, dirname) ⇒ ThinRepository
Returns a new instance of ThinRepository.
11 12 13 14 15 16 17 |
# File 'lib/r10k/git/shellgit/thin_repository.rb', line 11 def initialize(basedir, dirname) super if exist? && origin set_cache(origin) end end |
Instance Method Details
#cache ⇒ String
Returns The origin remote URL.
42 43 44 |
# File 'lib/r10k/git/shellgit/thin_repository.rb', line 42 def cache git(['config', '--get', 'remote.cache.url'], :path => @path.to_s, :raise_on_fail => false).stdout end |
#clone(remote, opts = {}) ⇒ void
This method returns an undefined value.
Clone this git repository
27 28 29 30 31 32 33 34 |
# File 'lib/r10k/git/shellgit/thin_repository.rb', line 27 def clone(remote, opts = {}) # todo check if opts[:reference] is set set_cache(remote) @cache_repo.sync super(remote, opts.merge(:reference => @cache_repo.git_dir.to_s)) setup_cache_remote end |
#fetch(remote = 'cache') ⇒ Object
Fetch refs from the backing bare Git repository.
37 38 39 |
# File 'lib/r10k/git/shellgit/thin_repository.rb', line 37 def fetch(remote = 'cache') git ['fetch', remote], :path => @path.to_s end |