diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-04-03 18:03:26 +0200 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-04-03 18:03:26 +0200 |
commit | e33ddfebf2248fe31bb27fe1d34048df97ed61b0 (patch) | |
tree | f7d5af3d3c48924beaf7c8ce9d67e2c09eee0dde /lib | |
parent | b492f0f86ea0f0b4e954e1b7ed0b84d08d784272 (diff) | |
download | gitlab-ce-e33ddfebf2248fe31bb27fe1d34048df97ed61b0.tar.gz |
Refactor ClosingIssueExtractor.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/closing_issue_extractor.rb | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/lib/gitlab/closing_issue_extractor.rb b/lib/gitlab/closing_issue_extractor.rb index 6425193d85f..ab184d95c05 100644 --- a/lib/gitlab/closing_issue_extractor.rb +++ b/lib/gitlab/closing_issue_extractor.rb @@ -1,21 +1,20 @@ module Gitlab - module ClosingIssueExtractor + class ClosingIssueExtractor ISSUE_CLOSING_REGEX = Regexp.new(Gitlab.config.gitlab.issue_closing_pattern) - def self.closed_by_message_in_project(message, project, current_user = nil) - issues = [] + def initialize(project, current_user = nil) + @extractor = Gitlab::ReferenceExtractor.new(project, current_user) + end - unless message.nil? - md = message.scan(ISSUE_CLOSING_REGEX) + def closed_by_message(message) + return [] if message.nil? + + closing_statements = message.scan(ISSUE_CLOSING_REGEX). + map { |ref| ref[0] }.join(" ") - md.each do |ref| - extractor = Gitlab::ReferenceExtractor.new(project, current_user) - extractor.analyze(ref[0]) - issues += extractor.issues - end - end + @extractor.analyze(closing_statements) - issues.uniq + @extractor.issues end end end |