Keep cross project reference logic in GroupLabel#to_reference

parent f74d5f27
...@@ -15,8 +15,20 @@ class GroupLabel < Label ...@@ -15,8 +15,20 @@ class GroupLabel < Label
# #
# Returns a String # Returns a String
# #
def to_reference(from_project = nil, format: :id) def to_reference(source_project = nil, target_project = nil, format: :id)
format_reference = label_format_reference(format) format_reference = label_format_reference(format)
"#{self.class.reference_prefix}#{format_reference}" reference = "#{self.class.reference_prefix}#{format_reference}"
if cross_project_reference?(source_project, target_project)
source_project.to_reference + reference
else
reference
end
end
private
def cross_project_reference?(source_project, target_project)
source_project && target_project && source_project != target_project
end end
end end
...@@ -76,15 +76,7 @@ module Gitlab ...@@ -76,15 +76,7 @@ module Gitlab
if referable.respond_to?(:project) if referable.respond_to?(:project)
referable.to_reference(target_project) referable.to_reference(target_project)
else else
to_reference(referable, target_project) referable.to_reference(@source_project, target_project)
end
end
def to_reference(referable, target_project)
if @source_project != target_project
@source_project.to_reference + referable.to_reference
else
referable.to_reference
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment