Class: GitCompound::Component::Version::SHA

Inherits:
VersionStrategy show all
Defined in:
lib/git_compound/component/version/sha.rb

Overview

Component version indicated by SHA hash

Instance Method Summary collapse

Methods inherited from VersionStrategy

#==

Constructor Details

#initialize(repository, sha) ⇒ SHA

Returns a new instance of SHA.



7
8
9
10
# File 'lib/git_compound/component/version/sha.rb', line 7

def initialize(repository, sha)
  @repository = repository
  @sha = sha
end

Instance Method Details

#reachable?Boolean

rubocop:enable Style/TrivialAccessors

Returns:

  • (Boolean)


27
28
29
30
31
32
# 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

#refObject

If sha matches ref in remote repository then

this ref should be returned

else return sha.



16
17
18
19
# 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

#shaObject

rubocop:disable Style/TrivialAccessors



22
23
24
# File 'lib/git_compound/component/version/sha.rb', line 22

def sha
  @sha
end

#to_sObject



34
35
36
# File 'lib/git_compound/component/version/sha.rb', line 34

def to_s
  "sha: #{@sha[0..7]}"
end