Commit 46b1664b authored by Marin Jankovski's avatar Marin Jankovski

Reference extractor needs to take into account external issue tracker.

parent 3b525558
...@@ -64,9 +64,10 @@ module Mentionable ...@@ -64,9 +64,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.issues_for(p) +
ext.merge_requests_for + ext.merge_requests_for(p) +
ext.commits_for).uniq - [local_reference] 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+.
......
...@@ -23,17 +23,13 @@ module Gitlab ...@@ -23,17 +23,13 @@ module Gitlab
end end
def issues_for(project = nil) def issues_for(project = nil)
if project && project.jira_tracker? issues.uniq.map do |entry|
issues.uniq.map do |jira_identifier| if should_lookup?(project, entry[:project])
JiraIssue.new(jira_identifier[:id]) entry[:project].issues.where(iid: entry[:id]).first
elsif external_jira_reference?(project, entry[:project])
JiraIssue.new(entry[:id], entry[:project])
end end
else end.reject(&:nil?)
issues.map do |entry|
if should_lookup?(project, entry[:project])
entry[:project].issues.where(iid: entry[:id]).first
end
end.reject(&:nil?)
end
end end
def merge_requests_for(project = nil) def merge_requests_for(project = nil)
...@@ -70,7 +66,15 @@ module Gitlab ...@@ -70,7 +66,15 @@ 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
def external_jira_reference?(project, entry_project)
if project.id == entry_project.id
project && project.jira_tracker?
else
entry_project && entry_project.jira_tracker?
end end
end end
end end
......
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