2018-08-03 13:22:24 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-04-21 22:26:58 -04:00
|
|
|
module Mentionable
|
|
|
|
module ReferenceRegexes
|
|
|
|
def self.reference_pattern(link_patterns, issue_pattern)
|
|
|
|
Regexp.union(link_patterns,
|
|
|
|
issue_pattern,
|
2018-08-29 09:38:42 -04:00
|
|
|
*other_patterns)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.other_patterns
|
|
|
|
[
|
|
|
|
Commit.reference_pattern,
|
|
|
|
MergeRequest.reference_pattern
|
|
|
|
]
|
2017-04-21 22:26:58 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
DEFAULT_PATTERN = begin
|
|
|
|
issue_pattern = Issue.reference_pattern
|
2018-08-29 09:38:42 -04:00
|
|
|
link_patterns = Regexp.union([Issue, Commit, MergeRequest, Epic].map(&:link_reference_pattern).compact)
|
2017-04-21 22:26:58 -04:00
|
|
|
reference_pattern(link_patterns, issue_pattern)
|
|
|
|
end
|
|
|
|
|
|
|
|
EXTERNAL_PATTERN = begin
|
2017-06-30 08:47:53 -04:00
|
|
|
issue_pattern = IssueTrackerService.reference_pattern
|
2017-04-21 22:26:58 -04:00
|
|
|
link_patterns = URI.regexp(%w(http https))
|
|
|
|
reference_pattern(link_patterns, issue_pattern)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|