Sha256: 85d8a8b55ebebbaaa2104d083bed30ea3292dfd2bbb7e11efba09d96ebce395f

Contents?: true

Size: 1 KB

Versions: 5

Compression:

Stored size: 1 KB

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

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

        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

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
git_compound-0.2.2 lib/git_compound/component/version/sha.rb
git_compound-0.2.1 lib/git_compound/component/version/sha.rb
git_compound-0.2.0 lib/git_compound/component/version/sha.rb
git_compound-0.1.2 lib/git_compound/component/version/sha.rb
git_compound-0.1.1 lib/git_compound/component/version/sha.rb