Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-12 03:09:34 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-12 03:09:34 +0300
commit5781a4966047232d4725f9ee4769c4bd5aed9b26 (patch)
tree0ef2b81a40931ec51f8fdd5284ed9e47cf42a923 /app/models/note.rb
parent4d48b3cfcd74bcca0f0f305746f74cf7224dd78b (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/note.rb')
-rw-r--r--app/models/note.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/models/note.rb b/app/models/note.rb
index 561391a55b6..670a981a78f 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -290,6 +290,19 @@ class Note < ApplicationRecord
@commit ||= project.commit(commit_id) if commit_id.present?
end
+ # Notes on merge requests and commits can be traced back to one or several
+ # MRs. This method returns a relation if the note is for one of these types,
+ # or nil if it is a note on some other object.
+ def merge_requests
+ if for_commit?
+ project.merge_requests.by_commit_sha(commit_id)
+ elsif for_merge_request?
+ MergeRequest.id_in(noteable_id)
+ else
+ nil
+ end
+ end
+
# override to return commits, which are not active record
def noteable
return commit if for_commit?