2020-11-24 15:15:51 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Atlassian
|
|
|
|
class JiraIssueKeyExtractor
|
2023-04-23 21:23:45 +05:30
|
|
|
def self.has_keys?(...)
|
|
|
|
new(...).issue_keys.any?
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|
|
|
|
|
2023-06-20 00:43:36 +05:30
|
|
|
def initialize(*text, custom_regex: nil)
|
2020-11-24 15:15:51 +05:30
|
|
|
@text = text.join(' ')
|
2023-06-20 00:43:36 +05:30
|
|
|
@match_regex = custom_regex || Gitlab::Regex.jira_issue_key_regex
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def issue_keys
|
2023-06-20 00:43:36 +05:30
|
|
|
@text.scan(@match_regex).flatten.uniq
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|