Class: R10K::Git::Rugged::BaseRepository

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/r10k/git/rugged/base_repository.rb

Direct Known Subclasses

BareRepository, WorkingRepository

Constant Summary

Constants included from Logging

Logging::LOG_LEVELS

Instance Method Summary collapse

Methods included from Logging

debug_formatter, default_formatter, default_outputter, #logger, #logger_name, parse_level

Instance Method Details

#branchesObject



22
23
24
# File 'lib/r10k/git/rugged/base_repository.rb', line 22

def branches
  with_repo { |repo| repo.branches.each_name(:local).to_a }
end

#ref_type(pattern) ⇒ Symbol

Returns The type of the given ref, one of :branch, :tag, :commit, or :unknown.

Returns:

  • (Symbol)

    The type of the given ref, one of :branch, :tag, :commit, or :unknown



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/r10k/git/rugged/base_repository.rb', line 31

def ref_type(pattern)
  if branches.include? pattern
    :branch
  elsif tags.include? pattern
    :tag
  elsif resolve(pattern)
    :commit
  else
    :unknown
  end
end

#resolve(pattern) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/r10k/git/rugged/base_repository.rb', line 8

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

#tagsObject



26
27
28
# File 'lib/r10k/git/rugged/base_repository.rb', line 26

def tags
  with_repo { |repo| repo.tags.each_name.to_a }
end