summaryrefslogtreecommitdiff
path: root/lib/gitlab/closing_issue_extractor.rb
blob: aeec595782c53fb012dcfc3fa00e67d37db27861 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module Gitlab
  class ClosingIssueExtractor
    ISSUE_CLOSING_REGEX = Regexp.new(Gitlab.config.gitlab.issue_closing_pattern)

    def initialize(project, current_user = nil)
      @extractor = Gitlab::ReferenceExtractor.new(project, current_user)
    end

    def closed_by_message(message)
      return [] if message.nil?

      closing_statements = message.scan(ISSUE_CLOSING_REGEX).
        map { |ref| ref[0] }.join(" ")

      @extractor.analyze(closing_statements)

      @extractor.issues
    end
  end
end