Commit 0e76daf3 authored by Gabriel Gizotti's avatar Gabriel Gizotti

only look for issues mentioned on description on MergeRequest#issues_mentioned_but_not_closing

parent c1515cd8
...@@ -570,18 +570,20 @@ class MergeRequest < ActiveRecord::Base ...@@ -570,18 +570,20 @@ class MergeRequest < ActiveRecord::Base
def issues_mentioned_but_not_closing(current_user = self.author) def issues_mentioned_but_not_closing(current_user = self.author)
issues = [] issues = []
closing_issues = []
if target_branch == project.default_branch if target_branch == project.default_branch
messages = [description] messages = [description]
messages.concat(commits.map(&:safe_message)) if merge_request_diff
ext = Gitlab::ReferenceExtractor.new(project, current_user) ext = Gitlab::ReferenceExtractor.new(project, current_user)
ext.analyze(messages.join("\n")) ext.analyze(messages.join("\n"))
issues = ext.issues issues = ext.issues
closing_issues = Gitlab::ClosingIssueExtractor.new(project, current_user).
closed_by_message(messages.join("\n"))
end end
issues - closes_issues issues - closing_issues
end end
def target_project_path def target_project_path
......
...@@ -294,7 +294,7 @@ describe MergeRequest, models: true do ...@@ -294,7 +294,7 @@ describe MergeRequest, models: true do
end end
end end
it 'detects issues mentioned but not closed' do it 'detects issues mentioned in description but not closed' do
mentioned_issue = create(:issue, project: subject.project) mentioned_issue = create(:issue, project: subject.project)
subject.description = "Is related to #{mentioned_issue.to_reference}" subject.description = "Is related to #{mentioned_issue.to_reference}"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment