Class: R10K::Git::Ref Private
- Inherits:
-
Object
- Object
- R10K::Git::Ref
- 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.
Instance Attribute Summary collapse
- #ref ⇒ Object readonly private
-
#repository ⇒ R10K::Git::Repository
A git repository that can be used to resolve the git reference to a commit.
Instance Method Summary collapse
- #==(other) ⇒ Object private
-
#fetch? ⇒ Boolean
private
Should we try to fetch this ref?.
-
#initialize(ref, repository = nil) ⇒ Ref
constructor
private
A new instance of Ref.
- #inspect ⇒ Object private
-
#resolvable? ⇒ Boolean
private
Can we locate the commit in the related repository?.
- #sha1 ⇒ Object private
- #to_s ⇒ Object private
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
#ref ⇒ Object (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 |
#repository ⇒ R10K::Git::Repository
Returns 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.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.
38 39 40 |
# File 'lib/r10k/git/ref.rb', line 38 def fetch? true end |
#inspect ⇒ 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.
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?
27 28 29 30 31 32 |
# File 'lib/r10k/git/ref.rb', line 27 def resolvable? sha1 true rescue R10K::Git::UnresolvableRefError false end |
#sha1 ⇒ 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.
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_s ⇒ 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.
56 57 58 |
# File 'lib/r10k/git/ref.rb', line 56 def to_s ref end |