Commit 3e8efce3 authored by Robert Speicher's avatar Robert Speicher

Refactor SystemNoteService.cross_reference_disallowed?

parent 83904275
...@@ -171,13 +171,20 @@ class SystemNoteService ...@@ -171,13 +171,20 @@ class SystemNoteService
note_text.start_with?(cross_reference_note_prefix) note_text.start_with?(cross_reference_note_prefix)
end end
# Determine if cross reference note should be created. # Check if a cross-reference is disallowed
# eg. mentioning a commit in MR comments which exists inside a MR #
# should not create "mentioned in" note. # This method prevents adding a "mentioned in !1" note on every single commit
# in a merge request.
#
# noteable - Noteable object being referenced
# mentioner - Mentionable object
#
# Returns Boolean
def self.cross_reference_disallowed?(noteable, mentioner) def self.cross_reference_disallowed?(noteable, mentioner)
if mentioner.kind_of?(MergeRequest) return false unless MergeRequest === mentioner
mentioner.commits.map(&:id).include? noteable.id return false unless Commit === noteable
end
mentioner.commits.include?(noteable)
end end
def self.cross_reference_exists?(noteable, mentioner) def self.cross_reference_exists?(noteable, mentioner)
......
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