Class: R10K::Git::ShellGit::ThinRepository

Inherits:
WorkingRepository show all
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

Instance Attribute Summary

Attributes inherited from WorkingRepository

#path

Instance Method Summary collapse

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

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

#cacheString

Returns The origin remote URL.

Returns:

  • (String)

    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

Parameters:

  • remote (String)

    The Git remote to clone

  • opts (Hash) (defaults to: {})


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], :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