2015-08-27 23:02:49 +00:00
|
|
|
require 'gitlab/markdown'
|
|
|
|
|
2015-04-03 00:46:43 +00:00
|
|
|
module Gitlab
|
|
|
|
module Markdown
|
|
|
|
# HTML filter that replaces merge request references with links. References
|
2015-04-14 22:34:01 +00:00
|
|
|
# to merge requests that do not exist are ignored.
|
2015-04-03 00:46:43 +00:00
|
|
|
#
|
|
|
|
# This filter supports cross-project references.
|
2015-11-16 20:56:28 +00:00
|
|
|
class MergeRequestReferenceFilter < AbstractReferenceFilter
|
|
|
|
def self.object_class
|
|
|
|
MergeRequest
|
2015-04-03 00:46:43 +00:00
|
|
|
end
|
|
|
|
|
2015-11-16 20:56:28 +00:00
|
|
|
def find_object(project, id)
|
|
|
|
project.merge_requests.find_by(iid: id)
|
2015-04-03 00:46:43 +00:00
|
|
|
end
|
|
|
|
|
2015-11-16 20:56:28 +00:00
|
|
|
def url_for_object(mr, project)
|
2015-08-26 01:42:46 +00:00
|
|
|
h = Gitlab::Application.routes.url_helpers
|
2015-04-03 00:46:43 +00:00
|
|
|
h.namespace_project_merge_request_url(project.namespace, project, mr,
|
|
|
|
only_path: context[:only_path])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|