Class: Gitlab::Git::Ref

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab_git/ref.rb

Direct Known Subclasses

Branch, Tag

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, target) ⇒ Ref

Returns a new instance of Ref.



21
22
23
# File 'lib/gitlab_git/ref.rb', line 21

def initialize(name, target)
  @name, @target = name.gsub(/\Arefs\/(tags|heads)\//, ''), target
end

Instance Attribute Details

#nameObject (readonly)

Branch or tag name without “refs/tags|heads” prefix



6
7
8
# File 'lib/gitlab_git/ref.rb', line 6

def name
  @name
end

#targetObject (readonly)

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



11
12
13
# File 'lib/gitlab_git/ref.rb', line 11

def target
  @target
end

Class Method Details

.extract_branch_name(str) ⇒ Object

Extract branch name from full ref path

Ex.

Ref.extract_branch_name('refs/heads/master') #=> 'master'


17
18
19
# File 'lib/gitlab_git/ref.rb', line 17

def self.extract_branch_name(str)
  str.gsub(/\Arefs\/heads\//, '')
end