Add ExternalIssue base model to make issue referencing more robust for external issue trackers.
This commit is contained in:
parent
2dfd219834
commit
29e606deec
|
@ -67,9 +67,10 @@ module Mentionable
|
||||||
return [] if text.blank?
|
return [] if text.blank?
|
||||||
ext = Gitlab::ReferenceExtractor.new
|
ext = Gitlab::ReferenceExtractor.new
|
||||||
ext.analyze(text, p)
|
ext.analyze(text, p)
|
||||||
(ext.issues_for +
|
|
||||||
ext.merge_requests_for +
|
(ext.issues_for(p) +
|
||||||
ext.commits_for).uniq - [local_reference]
|
ext.merge_requests_for(p) +
|
||||||
|
ext.commits_for(p)).uniq - [local_reference]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Create a cross-reference Note for each GFM reference to another Mentionable found in +mentionable_text+.
|
# Create a cross-reference Note for each GFM reference to another Mentionable found in +mentionable_text+.
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
class ExternalIssue
|
||||||
|
def initialize(issue_identifier, project)
|
||||||
|
@issue_identifier, @project = issue_identifier, project
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
@issue_identifier.to_s
|
||||||
|
end
|
||||||
|
|
||||||
|
def id
|
||||||
|
@issue_identifier.to_s
|
||||||
|
end
|
||||||
|
|
||||||
|
def iid
|
||||||
|
@issue_identifier.to_s
|
||||||
|
end
|
||||||
|
|
||||||
|
def ==(other)
|
||||||
|
other.is_a?(self.class) && (to_s == other.to_s)
|
||||||
|
end
|
||||||
|
|
||||||
|
def project
|
||||||
|
@project
|
||||||
|
end
|
||||||
|
end
|
|
@ -71,7 +71,7 @@ module Gitlab
|
||||||
if entry_project.nil?
|
if entry_project.nil?
|
||||||
false
|
false
|
||||||
else
|
else
|
||||||
project.nil? || project.id == entry_project.id
|
project.nil? || entry_project.default_issues_tracker?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue