Class: Gitlab::Git::Ref
- Inherits:
-
Object
- Object
- Gitlab::Git::Ref
- Includes:
- EncodingHelper
- Defined in:
- lib/gitlab/git/ref.rb
Constant Summary
Constants included from EncodingHelper
EncodingHelper::BOM_UTF8, EncodingHelper::ENCODING_CONFIDENCE_THRESHOLD, EncodingHelper::ESCAPED_CHARS, EncodingHelper::UNICODE_REPLACEMENT_CHARACTER
Instance Attribute Summary collapse
-
#dereferenced_target ⇒ Object
readonly
Dereferenced target Commit object to which the Ref points to.
-
#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(repository, name, target, dereferenced_target) ⇒ Ref
constructor
A new instance of Ref.
Methods included from EncodingHelper
#binary_io, #detect_binary?, #detect_encoding, #detect_libgit2_binary?, #encode!, #encode_binary, #encode_utf8, #encode_utf8_no_detect, #encode_utf8_with_escaping!, #encode_utf8_with_replacement_character, #force_encode_utf8, #strip_bom, #unquote_path
Constructor Details
#initialize(repository, name, target, dereferenced_target) ⇒ Ref
Returns a new instance of Ref.
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/gitlab/git/ref.rb', line 29 def initialize(repository, name, target, dereferenced_target) @name = Gitlab::Git.ref_name(name) @dereferenced_target = dereferenced_target @target = if target.respond_to?(:oid) target.oid elsif target.respond_to?(:name) target.name elsif target.is_a? String target end end |
Instance Attribute Details
#dereferenced_target ⇒ Object (readonly)
Dereferenced target Commit object to which the Ref points to
19 20 21 |
# File 'lib/gitlab/git/ref.rb', line 19 def dereferenced_target @dereferenced_target end |
#name ⇒ Object (readonly)
Branch or tag name without “refs/tags|heads” prefix
10 11 12 |
# File 'lib/gitlab/git/ref.rb', line 10 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
15 16 17 |
# File 'lib/gitlab/git/ref.rb', line 15 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'
25 26 27 |
# File 'lib/gitlab/git/ref.rb', line 25 def self.extract_branch_name(str) str.delete_prefix('refs/heads/') end |