Class: Gitlab::ClosingIssueExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/closing_issue_extractor.rb

Constant Summary collapse

ISSUE_CLOSING_REGEX =
begin
  link_pattern = URI.regexp(%w(http https))

  pattern = Gitlab.config.gitlab.issue_closing_pattern
  pattern = pattern.sub('%{issue_ref}', "(?:(?:#{link_pattern})|(?:#{Issue.reference_pattern}))")
  Regexp.new(pattern).freeze
end

Instance Method Summary collapse

Constructor Details

#initialize(project, current_user = nil) ⇒ ClosingIssueExtractor

Returns a new instance of ClosingIssueExtractor


11
12
13
# File 'lib/gitlab/closing_issue_extractor.rb', line 11

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

Instance Method Details

#closed_by_message(message) ⇒ Object


15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/gitlab/closing_issue_extractor.rb', line 15

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

  closing_statements = []
  message.scan(ISSUE_CLOSING_REGEX) do
    closing_statements << Regexp.last_match[0]
  end

  @extractor.analyze(closing_statements.join(" "))

  @extractor.issues
end