diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-05-10 23:52:03 -0400 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-05-11 00:01:16 -0400 |
commit | 3e8efce360e3dadac69554d0bdebdcfde918f6e7 (patch) | |
tree | cc4fbe0f9b8a41b586fdfa26d683ef2cba133f4e | |
parent | 83904275831511f6b17b33064255b669604e0e74 (diff) | |
download | gitlab-ce-3e8efce360e3dadac69554d0bdebdcfde918f6e7.tar.gz |
Refactor SystemNoteService.cross_reference_disallowed?
-rw-r--r-- | app/services/system_note_service.rb | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/app/services/system_note_service.rb b/app/services/system_note_service.rb index a1de050ca5a..0614f8689a4 100644 --- a/app/services/system_note_service.rb +++ b/app/services/system_note_service.rb @@ -171,13 +171,20 @@ class SystemNoteService note_text.start_with?(cross_reference_note_prefix) end - # Determine if cross reference note should be created. - # eg. mentioning a commit in MR comments which exists inside a MR - # should not create "mentioned in" note. + # Check if a cross-reference is disallowed + # + # 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) - if mentioner.kind_of?(MergeRequest) - mentioner.commits.map(&:id).include? noteable.id - end + return false unless MergeRequest === mentioner + return false unless Commit === noteable + + mentioner.commits.include?(noteable) end def self.cross_reference_exists?(noteable, mentioner) |