Class: ExtractsRef::RequestedRef

Inherits:
Object
  • Object
show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
lib/extracts_ref/requested_ref.rb

Constant Summary collapse

SYMBOLIC_REF_PREFIX =
%r{((refs/)?(heads|tags)/)+}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository, ref_type:, ref:) ⇒ RequestedRef

Returns a new instance of RequestedRef.



8
9
10
11
12
# File 'lib/extracts_ref/requested_ref.rb', line 8

def initialize(repository, ref_type:, ref:)
  @ref_type = ref_type
  @ref = ref
  @repository = repository
end

Instance Attribute Details

#refObject (readonly)

Returns the value of attribute ref.



14
15
16
# File 'lib/extracts_ref/requested_ref.rb', line 14

def ref
  @ref
end

#ref_typeObject (readonly)

Returns the value of attribute ref_type.



14
15
16
# File 'lib/extracts_ref/requested_ref.rb', line 14

def ref_type
  @ref_type
end

#repositoryObject (readonly)

Returns the value of attribute repository.



14
15
16
# File 'lib/extracts_ref/requested_ref.rb', line 14

def repository
  @repository
end

Instance Method Details

#findObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/extracts_ref/requested_ref.rb', line 16

def find
  case ref_type
  when 'tags'
    { ref_type: ref_type, commit: tag }
  when 'heads'
    { ref_type: ref_type, commit: branch }
  else
    commit_without_ref_type
  end
end