Class: R10K::Git::Ref Private

Inherits:
Object
  • Object
show all
Defined in:
lib/r10k/git/ref.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

ref: A 40-byte hex representation of a SHA1 or a name that denotes a particular object. They may be stored in a file under $GIT_DIR/refs/ directory, or in the $GIT_DIR/packed-refs file.

Direct Known Subclasses

Commit, Head, Tag

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ref, repository = nil) ⇒ Ref

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Ref.



21
22
23
24
# File 'lib/r10k/git/ref.rb', line 21

def initialize(ref, repository = nil)
  @ref = ref
  @repository = repository
end

Instance Attribute Details

#refObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



14
15
16
# File 'lib/r10k/git/ref.rb', line 14

def ref
  @ref
end

#repositoryR10K::Git::Repository

Returns A git repository that can be used to resolve the git reference to a commit.

Returns:

  • (R10K::Git::Repository)

    A git repository that can be used to resolve the git reference to a commit.



19
20
21
# File 'lib/r10k/git/ref.rb', line 19

def repository
  @repository
end

Instance Method Details

#==(other) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



50
51
52
53
54
# File 'lib/r10k/git/ref.rb', line 50

def ==(other)
  other.is_a?(R10K::Git::Ref) && other.sha1 == self.sha1
rescue ArgumentError, R10K::Git::UnresolvableRefError
  false
end

#fetch?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Should we try to fetch this ref?

Since we don’t know the type of this ref, we have to assume that it might be a branch and always update accordingly.

Returns:

  • (Boolean)


38
39
40
# File 'lib/r10k/git/ref.rb', line 38

def fetch?
  true
end

#inspectObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



60
61
62
# File 'lib/r10k/git/ref.rb', line 60

def inspect
  "#<#{self.class}: #{to_s}>"
end

#resolvable?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Can we locate the commit in the related repository?

Returns:

  • (Boolean)


27
28
29
30
31
32
# File 'lib/r10k/git/ref.rb', line 27

def resolvable?
  sha1
  true
rescue R10K::Git::UnresolvableRefError
  false
end

#sha1Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



42
43
44
45
46
47
48
# File 'lib/r10k/git/ref.rb', line 42

def sha1
  if @repository.nil?
    raise ArgumentError, "Cannot resolve #{self.inspect}: no associated git repository"
  else
    @repository.rev_parse(ref)
  end
end

#to_sObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



56
57
58
# File 'lib/r10k/git/ref.rb', line 56

def to_s
  ref
end