Sha256: 37f000b9c9ac3964118556d8a6e159dd2b1fce24f0d650583822172ea6482f99

Contents?: true

Size: 857 Bytes

Versions: 2

Compression:

Stored size: 857 Bytes

Contents

module Gitlab
  module Git
    class Ref
      # Branch or tag name
      # without "refs/tags|heads" prefix
      attr_reader :name

      # Target sha.
      # Usually it is commit sha but in case
      # when tag reference on other tag it can be tag sha
      attr_reader :target

      # Extract branch name from full ref path
      #
      # Ex.
      #   Ref.extract_branch_name('refs/heads/master') #=> 'master'
      def self.extract_branch_name(str)
        str.gsub(/\Arefs\/heads\//, '')
      end

      def initialize(name, target)
        @name = name.gsub(/\Arefs\/(tags|heads)\//, '')
        @target = if target.respond_to?(:oid)
                    target.oid
                  elsif target.respond_to?(:name)
                    target.name
                  else
                    nil
                  end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gitlab_git-6.2.2 lib/gitlab_git/ref.rb
gitlab_git-6.2.1 lib/gitlab_git/ref.rb