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

    def self.closed_by_message_in_project(message, project)
      issues = []

      unless message.nil?
        md = message.scan(ISSUE_CLOSING_REGEX)

        md.each do |ref|
          extractor = Gitlab::ReferenceExtractor.new
          extractor.analyze(ref[0], project)
          issues += extractor.issues_for(project)
        end
      end

      issues.uniq
    end
  end
end