diff options
author | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2014-06-13 18:19:08 +0400 |
---|---|---|
committer | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2014-06-13 19:25:44 +0400 |
commit | 3f1ece26909f90e538a50cd724b64da28f0b7308 (patch) | |
tree | 1f10f7efef48602ef910d71b0f3411d34654e57a /app/models | |
parent | 5fdcaadf347e41109f20a4dee733f5b51030feda (diff) |
Detect closing issues in Merge Request description
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/commit.rb | 14 | ||||
-rw-r--r-- | app/models/merge_request.rb | 4 |
2 files changed, 4 insertions, 14 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb index 81875e1be2d..82876e10446 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -111,22 +111,10 @@ class Commit description.present? end - # Regular expression that identifies commit message clauses that trigger issue closing. - def issue_closing_regex - @issue_closing_regex ||= Regexp.new(Gitlab.config.gitlab.issue_closing_pattern) - end - # Discover issues should be closed when this commit is pushed to a project's # default branch. def closes_issues project - md = issue_closing_regex.match(safe_message) - if md - extractor = Gitlab::ReferenceExtractor.new - extractor.analyze(md[0]) - extractor.issues_for(project) - else - [] - end + Gitlab::ClosingIssueExtractor.closed_by_message_in_project(safe_message, project) end # Mentionable override. diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index a501870115f..bfea209bf6d 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -220,7 +220,9 @@ class MergeRequest < ActiveRecord::Base # Return the set of issues that will be closed if this merge request is accepted. def closes_issues if target_branch == project.default_branch - commits.map { |c| c.closes_issues(project) }.flatten.uniq.sort_by(&:id) + issues = commits.flat_map { |c| c.closes_issues(project) } + issues += Gitlab::ClosingIssueExtractor.closed_by_message_in_project(description, project) + issues.uniq.sort_by(&:id) else [] end |