BigW Consortium Gitlab

Commit fa639df5 by Grzegorz Bizon

Remove redundant code in cross project labels implementation

parent 34769efa
......@@ -85,7 +85,8 @@ class Label < ActiveRecord::Base
# Returns a String
#
def to_reference(from_project = nil, format: :id)
reference = label_format_reference(format)
format_reference = label_format_reference(format)
reference = "#{self.class.reference_prefix}#{format_reference}"
if cross_project_reference?(from_project)
project.to_reference + reference
......@@ -116,9 +117,9 @@ class Label < ActiveRecord::Base
raise StandardError, 'Unknown format' unless [:id, :name].include?(format)
if format == :name && !name.include?('"')
%(#{self.class.reference_prefix}"#{name}")
%("#{name}")
else
"#{self.class.reference_prefix}#{id}"
id
end
end
end
......@@ -16,10 +16,6 @@ module Banzai
end
end
def self.referenced_by(node)
{ label: LazyReference.new(Label, node.attr("data-label")) }
end
def references_in(text, pattern = Label.reference_pattern)
text.gsub(pattern) do |match|
project = project_from_ref($~[:project])
......
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