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
Logging::LOG_LEVELS, Logging::SYSLOG_LEVELS_MAP
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, cache_repo) ⇒ ThinRepository
constructor
A new instance of ThinRepository.
- #stage_files(files = ['.']) ⇒ Object
- #tracked_paths(ref = "HEAD") ⇒ Object
Methods inherited from WorkingRepository
#alternates, #checkout, #dirty?, #exist?, #git_dir, #head, #origin
Methods inherited from BaseRepository
#branches, #git_dir, #is_branch?, #is_tag?, #ref_type, #remotes, #resolve, #tags
Methods included from Logging
add_outputters, debug_formatter, default_formatter, default_outputter, #logger, #logger_name, parse_level
Constructor Details
#initialize(basedir, dirname, cache_repo) ⇒ ThinRepository
Returns a new instance of ThinRepository.
11 12 13 14 |
# File 'lib/r10k/git/shellgit/thin_repository.rb', line 11 def initialize(basedir, dirname, cache_repo) @cache_repo = cache_repo super(basedir, dirname) end |
Instance Method Details
#cache ⇒ String
Returns The origin remote URL.
38 39 40 |
# File 'lib/r10k/git/shellgit/thin_repository.rb', line 38 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
24 25 26 27 28 29 30 |
# File 'lib/r10k/git/shellgit/thin_repository.rb', line 24 def clone(remote, opts = {}) # todo check if opts[:reference] is set @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.
33 34 35 |
# File 'lib/r10k/git/shellgit/thin_repository.rb', line 33 def fetch(remote = 'cache') git ['fetch', remote, '--prune'], :path => @path.to_s end |
#stage_files(files = ['.']) ⇒ Object
46 47 48 |
# File 'lib/r10k/git/shellgit/thin_repository.rb', line 46 def stage_files(files=['.']) git(['add', files].flatten, :path => @path.to_s) end |
#tracked_paths(ref = "HEAD") ⇒ Object
42 43 44 |
# File 'lib/r10k/git/shellgit/thin_repository.rb', line 42 def tracked_paths(ref="HEAD") git(['ls-tree', '-t', '-r', '--name-only', ref], :path => @path.to_s).stdout.split("\n") end |