diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-01-05 16:40:23 +0100 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-01-05 16:40:23 +0100 |
commit | fd91b48f24d9f9d5e8f357b7b5324d279ce41077 (patch) | |
tree | cfa6e79e3bdbfde4b67b7bc549b6c3548a66bdaf /lib/gitlab/reference_extractor.rb | |
parent | 7dedd997b910f65ee3c494d906fbc2392962c114 (diff) | |
parent | 7c3c901ada6fc4a6d2d3ce7a2cf8188cf6615008 (diff) | |
download | gitlab-ce-fd91b48f24d9f9d5e8f357b7b5324d279ce41077.tar.gz |
Merge branch 'master' into milestone-ref
Diffstat (limited to 'lib/gitlab/reference_extractor.rb')
-rw-r--r-- | lib/gitlab/reference_extractor.rb | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/gitlab/reference_extractor.rb b/lib/gitlab/reference_extractor.rb index c87068051ab..4164e998dd1 100644 --- a/lib/gitlab/reference_extractor.rb +++ b/lib/gitlab/reference_extractor.rb @@ -3,11 +3,12 @@ require 'banzai' module Gitlab # Extract possible GFM references from an arbitrary String for further processing. class ReferenceExtractor < Banzai::ReferenceExtractor - attr_accessor :project, :current_user + attr_accessor :project, :current_user, :author - def initialize(project, current_user = nil) + def initialize(project, current_user = nil, author = nil) @project = project @current_user = current_user + @author = author @references = {} @@ -20,18 +21,22 @@ module Gitlab %i(user label milestone merge_request snippet commit commit_range).each do |type| define_method("#{type}s") do - @references[type] ||= references(type, project: project, current_user: current_user) + @references[type] ||= references(type, reference_context) end end def issues - options = { project: project, current_user: current_user } - if project && project.jira_tracker? - @references[:external_issue] ||= references(:external_issue, options) + @references[:external_issue] ||= references(:external_issue, reference_context) else - @references[:issue] ||= references(:issue, options) + @references[:issue] ||= references(:issue, reference_context) end end + + private + + def reference_context + { project: project, current_user: current_user, author: author } + end end end |