debian-mirror-gitlab/lib/gitlab/git/ref.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

44 lines
1.2 KiB
Ruby
Raw Normal View History

2019-02-15 15:39:39 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
module Gitlab
module Git
class Ref
2017-09-10 17:25:29 +05:30
include Gitlab::EncodingHelper
2019-05-03 19:53:19 +05:30
include Gitlab::Git::RuggedImpl::Ref
2017-08-17 22:00:37 +05:30
# 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
# Dereferenced target
# Commit object to which the Ref points to
attr_reader :dereferenced_target
# Extract branch name from full ref path
#
# Ex.
# Ref.extract_branch_name('refs/heads/master') #=> 'master'
def self.extract_branch_name(str)
2022-06-21 17:19:12 +05:30
str.delete_prefix('refs/heads/')
2017-08-17 22:00:37 +05:30
end
2018-03-17 18:26:18 +05:30
def initialize(repository, name, target, dereferenced_target)
2017-09-10 17:25:29 +05:30
@name = Gitlab::Git.ref_name(name)
2018-03-17 18:26:18 +05:30
@dereferenced_target = dereferenced_target
2017-08-17 22:00:37 +05:30
@target = if target.respond_to?(:oid)
target.oid
elsif target.respond_to?(:name)
target.name
elsif target.is_a? String
target
end
end
end
end
end