summaryrefslogtreecommitdiff
path: root/lib/extracts_ref.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/extracts_ref.rb')
-rw-r--r--lib/extracts_ref.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/extracts_ref.rb b/lib/extracts_ref.rb
index 9799116038e..f22996df0a5 100644
--- a/lib/extracts_ref.rb
+++ b/lib/extracts_ref.rb
@@ -64,10 +64,16 @@ module ExtractsRef
def assign_ref_vars
@id, @ref, @path = extract_ref_path
@repo = repository_container.repository
-
raise InvalidPathError if @ref.match?(/\s/)
- @commit = @repo.commit(@ref) if @ref.present?
+ return unless @ref.present?
+
+ @commit = if ref_type && Feature.enabled?(:use_ref_type_parameter, @repo.project)
+ @fully_qualified_ref = %(refs/#{ref_type}/#{@ref})
+ @repo.commit(@fully_qualified_ref)
+ else
+ @repo.commit(@ref)
+ end
end
# rubocop:enable Gitlab/ModuleWithInstanceVariables
@@ -82,6 +88,12 @@ module ExtractsRef
[id, ref, path]
end
+ def ref_type
+ return unless params[:ref_type].present?
+
+ params[:ref_type] == 'tags' ? 'tags' : 'heads'
+ end
+
private
def extract_raw_ref(id)