Welcome to mirror list, hosted at ThFree Co, Russian Federation.

jira_issue_key_extractor.rb « atlassian « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 17fa40e5676c4c7b01cdd96b5db8e437cfd5af5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

module Atlassian
  class JiraIssueKeyExtractor
    def self.has_keys?(...)
      new(...).issue_keys.any?
    end

    def initialize(*text, custom_regex: nil)
      @text = text.join(' ')
      @match_regex = custom_regex || Gitlab::Regex.jira_issue_key_regex
    end

    def issue_keys
      return @text.scan(@match_regex).flatten.uniq if @match_regex.is_a?(Regexp)

      @match_regex.scan(@text).flatten.uniq
    end
  end
end