2018-11-20 20:47:30 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
module Mentionable
|
|
|
|
module ReferenceRegexes
|
|
|
|
def self.reference_pattern(link_patterns, issue_pattern)
|
|
|
|
Regexp.union(link_patterns,
|
|
|
|
issue_pattern,
|
|
|
|
Commit.reference_pattern,
|
|
|
|
MergeRequest.reference_pattern)
|
|
|
|
end
|
|
|
|
|
|
|
|
DEFAULT_PATTERN = begin
|
|
|
|
issue_pattern = Issue.reference_pattern
|
|
|
|
link_patterns = Regexp.union([Issue, Commit, MergeRequest].map(&:link_reference_pattern))
|
|
|
|
reference_pattern(link_patterns, issue_pattern)
|
|
|
|
end
|
|
|
|
|
|
|
|
EXTERNAL_PATTERN = begin
|
|
|
|
issue_pattern = IssueTrackerService.reference_pattern
|
|
|
|
link_patterns = URI.regexp(%w(http https))
|
|
|
|
reference_pattern(link_patterns, issue_pattern)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|