class GitCompound::Component::Version::SHA

Component version indicated by SHA hash

Public Class Methods

new(repository, sha) click to toggle source
# File lib/git_compound/component/version/sha.rb, line 7
def initialize(repository, sha)
  @repository = repository
  @sha = sha
end

Public Instance Methods

reachable?() click to toggle source

rubocop:enable Style/TrivialAccessors

# File lib/git_compound/component/version/sha.rb, line 27
def reachable?
  # TODO, we assume that SHA is always available as we do not want
  # to clone repository and check if commit exists -- this probably
  # needs to be changed when someone finds better solution for this.
  true
end
ref() click to toggle source

If sha matches ref in remote repository then

this ref should be returned

else return sha.

# File lib/git_compound/component/version/sha.rb, line 16
def ref
  ref = @repository.refs.find { |refs_a| refs_a.include?(@sha) }
  ref ? ref.last : @sha
end
sha() click to toggle source

rubocop:disable Style/TrivialAccessors

# File lib/git_compound/component/version/sha.rb, line 22
def sha
  @sha
end
to_s() click to toggle source
# File lib/git_compound/component/version/sha.rb, line 34
def to_s
  "sha: #{@sha[0..7]}"
end