@return [Pathname] The path to this repository. @note The `@path` instance variable must be set by inheriting classes on instantiation.
# File lib/r10k/git/rugged/base_repository.rb, line 27 def branches with_repo { |repo| repo.branches.each_name(:local).to_a } end
@return [Symbol] The type of the given ref, one of :branch, :tag, :commit, or :unknown
# File lib/r10k/git/rugged/base_repository.rb, line 36 def ref_type(pattern) if branches.include? pattern :branch elsif tags.include? pattern :tag elsif resolve(pattern) :commit else :unknown end end
# File lib/r10k/git/rugged/base_repository.rb, line 48 def remotes remotes_hash = {} if @_rugged_repo @_rugged_repo.remotes.each do |remote| remotes_hash[remote.name] = remote.url end end remotes_hash end
# File lib/r10k/git/rugged/base_repository.rb, line 13 def resolve(pattern) object = with_repo { |repo| repo.rev_parse(pattern) } case object when NilClass nil when ::Rugged::Tag, ::Rugged::Tag::Annotation object.target.oid else object.oid end rescue ::Rugged::ReferenceError nil end
Generate a lambda that can create a credentials object for the authentication type in question.
@note The Rugged API expects an object that responds to call; the
Credentials subclasses implement #call returning self so that the Credentials object can be used, or a Proc that returns a Credentials object can be used.
@api private
@return [Proc]
# File lib/r10k/git/rugged/base_repository.rb, line 82 def credentials R10K::Git::Rugged::Credentials.new(self) end
# File lib/r10k/git/rugged/base_repository.rb, line 86 def report_transfer(results, remote) logger.debug2 { "Transferred #{results[:total_objects]} objects (#{results[:received_bytes]} bytes) from '#{remote}' into #{git_dir}'" } nil end
# File lib/r10k/git/rugged/base_repository.rb, line 62 def with_repo(opts={}) if @_rugged_repo yield @_rugged_repo end ensure @_rugged_repo.close if @_rugged_repo end