Sha256: de8552ef0460a85e837fa6e7f8c2ad34d1f27f3c8921ca93cad12990b05d2c5a
Contents?: true
Size: 1.56 KB
Versions: 1
Compression:
Stored size: 1.56 KB
Contents
require 'r10k/git' require 'r10k/git/repository' # 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. # # @deprecated This has been replaced by the ShellGit provider and the # StatefulRepository class and will be removed in 2.0.0 # # @see https://www.kernel.org/pub/software/scm/git/docs/gitglossary.html # @api private class R10K::Git::Ref # @!attribute [r] ref # @return [String] The git reference attr_reader :ref # @!attribute [rw] repository # @return [R10K::Git::Repository] A git repository that can be used to # resolve the git reference to a commit. attr_accessor :repository def initialize(ref, repository = nil) @ref = ref @repository = repository end # Can we locate the commit in the related repository? def resolvable? sha1 true rescue R10K::Git::UnresolvableRefError false end # 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. def fetch? true end def sha1 if @repository.nil? raise ArgumentError, "Cannot resolve #{self.inspect}: no associated git repository" else @repository.rev_parse(ref) end end def ==(other) other.is_a?(R10K::Git::Ref) && other.sha1 == self.sha1 rescue ArgumentError, R10K::Git::UnresolvableRefError false end def to_s ref end def inspect "#<#{self.class}: #{to_s}>" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
r10k-1.5.1 | lib/r10k/git/ref.rb |