Sha256: 1942c20d0a0e1f198ec56bf983f289fe0dad92b294c49ffc4dd00fbec601240e

Contents?: true

Size: 469 Bytes

Versions: 1

Compression:

Stored size: 469 Bytes

Contents

module Regrit
  class Ref
    def initialize(repo, ref)
      @repo = repo
      @commit, @full_name = ref.split(/\t/)
      @type, @name = @full_name.scan(%r#refs/([^/]+)/(.+)#).first || [nil, @full_name]
      raise InvalidRefsFormat.new(ref) if @name.nil?
    end

    attr_reader :commit, :full_name, :name, :type

    def tag?
      type == 'tags'
    end

    def branch?
      type == 'heads'
    end

    def abbrev_commit
      commit[0...7]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
regrit-0.2.0 lib/regrit/ref.rb