summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarin Jankovski <maxlazio@gmail.com>2015-02-02 15:11:19 -0800
committerMarin Jankovski <maxlazio@gmail.com>2015-02-11 09:21:57 -0800
commit29e606deeca83c41d72f880d9574af5983686ab3 (patch)
tree9dfca41ccb3ae3a3c075d1b217e206a98bebf8ec
parent2dfd21983483bd5fd32b327edb4b02228b377c47 (diff)
downloadgitlab-ce-29e606deeca83c41d72f880d9574af5983686ab3.tar.gz
Add ExternalIssue base model to make issue referencing more robust for external issue trackers.
-rw-r--r--app/models/concerns/mentionable.rb7
-rw-r--r--app/models/external_issue.rb25
-rw-r--r--lib/gitlab/reference_extractor.rb2
3 files changed, 30 insertions, 4 deletions
diff --git a/app/models/concerns/mentionable.rb b/app/models/concerns/mentionable.rb
index d640728519a..50be458bf24 100644
--- a/app/models/concerns/mentionable.rb
+++ b/app/models/concerns/mentionable.rb
@@ -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+.
diff --git a/app/models/external_issue.rb b/app/models/external_issue.rb
new file mode 100644
index 00000000000..50efcb32f1b
--- /dev/null
+++ b/app/models/external_issue.rb
@@ -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
diff --git a/lib/gitlab/reference_extractor.rb b/lib/gitlab/reference_extractor.rb
index 0b9177afa4f..7e5c991a222 100644
--- a/lib/gitlab/reference_extractor.rb
+++ b/lib/gitlab/reference_extractor.rb
@@ -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