Add ExternalIssue base model to make issue referencing more robust for external issue trackers.

This commit is contained in:
Marin Jankovski 2015-02-02 15:11:19 -08:00
parent 2dfd219834
commit 29e606deec
3 changed files with 30 additions and 4 deletions

View File

@ -67,9 +67,10 @@ module Mentionable
return [] if text.blank?
ext = Gitlab::ReferenceExtractor.new
ext.analyze(text, p)
(ext.issues_for +
ext.merge_requests_for +
ext.commits_for).uniq - [local_reference]
(ext.issues_for(p) +
ext.merge_requests_for(p) +
ext.commits_for(p)).uniq - [local_reference]
end
# Create a cross-reference Note for each GFM reference to another Mentionable found in +mentionable_text+.

View File

@ -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

View File

@ -71,7 +71,7 @@ module Gitlab
if entry_project.nil?
false
else
project.nil? || project.id == entry_project.id
project.nil? || entry_project.default_issues_tracker?
end
end
end