Class: R10K::Git::Rugged::ThinRepository
- Inherits:
-
WorkingRepository
- Object
- BaseRepository
- WorkingRepository
- R10K::Git::Rugged::ThinRepository
- Defined in:
- lib/r10k/git/rugged/thin_repository.rb
Constant Summary
Constants included from Logging
Instance Attribute Summary
Attributes inherited from WorkingRepository
Instance Method Summary collapse
-
#cache ⇒ String
The cache remote URL.
- #checkout(ref) ⇒ Object
-
#clone(remote, opts = {}) ⇒ void
Clone this git repository.
-
#fetch(remote = 'cache') ⇒ void
Fetch refs and objects from one of the Git remotes.
-
#initialize(basedir, dirname) ⇒ ThinRepository
constructor
A new instance of ThinRepository.
Methods inherited from WorkingRepository
#alternates, #exist?, #git_dir, #head, #origin
Methods inherited from BaseRepository
#branches, #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.
6 7 8 9 10 11 12 |
# File 'lib/r10k/git/rugged/thin_repository.rb', line 6 def initialize(basedir, dirname) super if exist? && origin set_cache(origin) end end |
Instance Method Details
#cache ⇒ String
Returns The cache remote URL.
63 64 65 |
# File 'lib/r10k/git/rugged/thin_repository.rb', line 63 def cache with_repo { |repo| repo.config['remote.cache.url'] } end |
#checkout(ref) ⇒ Object
50 51 52 |
# File 'lib/r10k/git/rugged/thin_repository.rb', line 50 def checkout(ref) super(@cache_repo.resolve(ref)) end |
#clone(remote, opts = {}) ⇒ void
This method returns an undefined value.
Clone this git repository
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/r10k/git/rugged/thin_repository.rb', line 22 def clone(remote, opts = {}) logger.debug1 { "Cloning '#{remote}' into #{@path}" } set_cache(remote) @cache_repo.sync objectpath = (@cache_repo.git_dir + 'objects').to_s # {Rugged::Repository.clone_at} doesn't support :alternates, which # completely breaks how thin repositories need to work. To circumvent # this we manually create a Git repository, set up git remotes, and # update 'objects/info/alternates' with the path. We don't actually # fetch any objects because we don't need them, and we don't actually # use any refs in this repository so we skip all those steps. ::Rugged::Repository.init_at(@path.to_s, false) @_rugged_repo = ::Rugged::Repository.new(@path.to_s, :alternates => [objectpath]) alternates << objectpath with_repo do |repo| config = repo.config config['remote.origin.url'] = remote config['remote.origin.fetch'] = '+refs/heads/*:refs/remotes/origin/*' config['remote.cache.url'] = @cache_repo.git_dir.to_s config['remote.cache.fetch'] = '+refs/heads/*:refs/remotes/cache/*' end checkout(opts.fetch(:ref, 'HEAD')) end |
#fetch(remote = 'cache') ⇒ void
This method returns an undefined value.
Fetch refs and objects from one of the Git remotes
58 59 60 |
# File 'lib/r10k/git/rugged/thin_repository.rb', line 58 def fetch(remote = 'cache') super(remote) end |