Class: GitCompound::Component::Version::SHA
- Inherits:
-
VersionStrategy
- Object
- VersionStrategy
- GitCompound::Component::Version::SHA
- Defined in:
- lib/git_compound/component/version/sha.rb
Overview
Component version indicated by SHA hash
Instance Method Summary collapse
-
#initialize(repository, sha) ⇒ SHA
constructor
A new instance of SHA.
-
#reachable? ⇒ Boolean
rubocop:enable Style/TrivialAccessors.
-
#ref ⇒ Object
If sha matches ref in remote repository then this ref should be returned else return sha.
-
#sha ⇒ Object
rubocop:disable Style/TrivialAccessors.
- #to_s ⇒ Object
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
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 |
#ref ⇒ Object
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 |
#sha ⇒ Object
rubocop:disable Style/TrivialAccessors
22 23 24 |
# File 'lib/git_compound/component/version/sha.rb', line 22 def sha @sha end |
#to_s ⇒ Object
34 35 36 |
# File 'lib/git_compound/component/version/sha.rb', line 34 def to_s "sha: #{@sha[0..7]}" end |