Class: R10K::Git::Rugged::BareRepository
- Inherits:
-
BaseRepository
- Object
- BaseRepository
- R10K::Git::Rugged::BareRepository
- Defined in:
- lib/r10k/git/rugged/bare_repository.rb
Constant Summary
Constants included from Logging
Logging::LOG_LEVELS, Logging::SYSLOG_LEVELS_MAP
Instance Attribute Summary
Attributes inherited from BaseRepository
Instance Method Summary collapse
-
#clone(remote) ⇒ void
Clone the given remote.
- #exist? ⇒ Boolean
-
#fetch(remote_name = 'origin') ⇒ void
Fetch refs and objects from the origin remote.
-
#git_dir ⇒ Pathname
The path to this Git repository.
-
#initialize(basedir, dirname) ⇒ BareRepository
constructor
A new instance of BareRepository.
-
#objects_dir ⇒ Pathname
The path to the objects directory in this Git repository.
Methods inherited from BaseRepository
#branches, #ref_type, #remotes, #resolve, #tags, #update_remote
Methods included from Logging
add_outputters, debug_formatter, default_formatter, default_outputter, #logger, #logger_name, parse_level
Constructor Details
#initialize(basedir, dirname) ⇒ BareRepository
Returns a new instance of BareRepository.
9 10 11 12 13 14 15 |
# File 'lib/r10k/git/rugged/bare_repository.rb', line 9 def initialize(basedir, dirname) @path = Pathname.new(File.join(basedir, dirname)) if exist? @_rugged_repo = ::Rugged::Repository.(@path.to_s) end end |
Instance Method Details
#clone(remote) ⇒ void
This method returns an undefined value.
Clone the given remote.
This should only be called if the repository does not exist.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/r10k/git/rugged/bare_repository.rb', line 33 def clone(remote) logger.debug1 { _("Cloning '%{remote}' into %{path}") % {remote: remote, path: @path} } @_rugged_repo = ::Rugged::Repository.init_at(@path.to_s, true).tap do |repo| config = repo.config config['remote.origin.url'] = remote config['remote.origin.fetch'] = '+refs/heads/*:refs/heads/*' config['remote.origin.mirror'] = 'true' end fetch('origin') rescue Rugged::SshError, Rugged::NetworkError => e raise R10K::Git::GitError.new(e., :git_dir => git_dir, :backtrace => e.backtrace) end |
#exist? ⇒ Boolean
83 84 85 |
# File 'lib/r10k/git/rugged/bare_repository.rb', line 83 def exist? @path.exist? end |
#fetch(remote_name = 'origin') ⇒ void
This method returns an undefined value.
Fetch refs and objects from the origin remote
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/r10k/git/rugged/bare_repository.rb', line 51 def fetch(remote_name='origin') logger.debug1 { _("Fetching remote '%{remote_name}' at %{path}") % {remote_name: remote_name, path: @path } } # Check to see if we have a version of Rugged that supports "fetch --prune" and warn if not if defined?(Rugged::Version) && !Gem::Dependency.new('rugged', '>= 0.24.0').match?('rugged', Rugged::Version) logger.warn { _("Rugged versions prior to 0.24.0 do not support pruning stale branches during fetch, please upgrade your \'rugged\' gem. (Current version is: %{version})") % {version: Rugged::Version} } end remote = remotes[remote_name] proxy = R10K::Git.get_proxy_for_remote(remote) = {:credentials => credentials, :prune => true, :proxy_url => proxy} refspecs = ['+refs/heads/*:refs/heads/*'] results = nil R10K::Git.with_proxy(proxy) do results = with_repo { |repo| repo.fetch(remote_name, refspecs, **) } end report_transfer(results, remote_name) rescue Rugged::SshError, Rugged::NetworkError => e if e. =~ /Unsupported proxy scheme for/ = e. + "As of curl ver 7.50.2, unsupported proxy schemes no longer fall back to HTTP." else = e. end raise R10K::Git::GitError.new(, :git_dir => git_dir, :backtrace => e.backtrace) rescue raise end |
#git_dir ⇒ Pathname
Returns The path to this Git repository.
18 19 20 |
# File 'lib/r10k/git/rugged/bare_repository.rb', line 18 def git_dir @path end |
#objects_dir ⇒ Pathname
Returns The path to the objects directory in this Git repository.
23 24 25 |
# File 'lib/r10k/git/rugged/bare_repository.rb', line 23 def objects_dir @path + "objects" end |