Commit fa639df5 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Remove redundant code in cross project labels implementation

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