Sha256: dacee7e7fc7ee36eccec35389156d07971a27d719bd0449896c93ed4cb2c5ab1

Contents?: true

Size: 985 Bytes

Versions: 60

Compression:

Stored size: 985 Bytes

Contents

module Gitlab
  module Git
    class Ref
      include EncodingHelper
      
      # 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)
        encode! name
        @name = name.gsub(/\Arefs\/(tags|heads)\//, '')
        @target = if target.respond_to?(:oid)
                    target.oid
                  elsif target.respond_to?(:name)
                    target.name
                  elsif target.is_a? String
                    target
                  else
                    nil
                  end
      end
    end
  end
end

Version data entries

60 entries across 60 versions & 1 rubygems

Version Path
gitlab_git-10.3.2 lib/gitlab_git/ref.rb
gitlab_git-10.3.1 lib/gitlab_git/ref.rb
gitlab_git-10.3.0 lib/gitlab_git/ref.rb
gitlab_git-10.2.3 lib/gitlab_git/ref.rb
gitlab_git-10.2.2 lib/gitlab_git/ref.rb
gitlab_git-10.2.1 lib/gitlab_git/ref.rb
gitlab_git-10.2.0 lib/gitlab_git/ref.rb
gitlab_git-10.1.4 lib/gitlab_git/ref.rb
gitlab_git-10.1.3 lib/gitlab_git/ref.rb
gitlab_git-10.1.2 lib/gitlab_git/ref.rb
gitlab_git-10.1.1 lib/gitlab_git/ref.rb
gitlab_git-10.1.0 lib/gitlab_git/ref.rb
gitlab_git-10.0.2 lib/gitlab_git/ref.rb
gitlab_git-10.0.1 lib/gitlab_git/ref.rb
gitlab_git-10.0.0 lib/gitlab_git/ref.rb
gitlab_git-9.0.3 lib/gitlab_git/ref.rb
gitlab_git-9.0.2 lib/gitlab_git/ref.rb
gitlab_git-9.0.1 lib/gitlab_git/ref.rb
gitlab_git-9.0.0 lib/gitlab_git/ref.rb
gitlab_git-8.2.0 lib/gitlab_git/ref.rb