Class: Gitlab::Git::Ref
- Inherits:
-
Object
- Object
- Gitlab::Git::Ref
- Defined in:
- lib/gitlab_git/ref.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Branch or tag name without “refs/tags|heads” prefix.
-
#target ⇒ Object
readonly
Target sha.
Class Method Summary collapse
-
.extract_branch_name(str) ⇒ Object
Extract branch name from full ref path.
Instance Method Summary collapse
-
#initialize(name, target) ⇒ Ref
constructor
A new instance of Ref.
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
#name ⇒ Object (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 |
#target ⇒ Object (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 |