Add ExternalIssue base model to make issue referencing more robust for external issue trackers.
This commit is contained in:
parent
2dfd219834
commit
29e606deec
3 changed files with 30 additions and 4 deletions
|
@ -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+.
|
||||
|
|
25
app/models/external_issue.rb
Normal file
25
app/models/external_issue.rb
Normal 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
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue