Sha256: f793acf916cab627e10acee59408dfb63fdbcaf791bd5d3f59bf16319d086f38

Contents?: true

Size: 922 Bytes

Versions: 1

Compression:

Stored size: 922 Bytes

Contents

module GitCompound
  class Component
    module Version
      # Component version indicated by SHA hash
      #
      class SHA < VersionStrategy
        def initialize(repository, sha)
          @repository = repository
          @sha = sha
        end

        # If @sha matches ref in remote repository then
        #   this ref should be returned
        # else return @sha.
        #
        def ref
          ref = @repository.refs.find { |refs_a| refs_a.include?(@sha) }
          ref ? ref.last : @sha
        end

        def sha # rubocop:disable Style/TrivialAccessors
          @sha
        end

        def reachable?
          # We assume that SHA is always available as we do not want
          # to clone repository and check it -- this probably needs
          # to be changed, so -- TODO
          true
        end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
git_compound-0.1.0 lib/git_compound/component/version/sha.rb