diff options
author | Riyad Preukschas <riyad@informatik.uni-bremen.de> | 2012-10-10 12:06:30 +0200 |
---|---|---|
committer | Riyad Preukschas <riyad@informatik.uni-bremen.de> | 2012-10-10 12:06:30 +0200 |
commit | 3f72af9994554c66a51cdfb4302e48da0edd043a (patch) | |
tree | 9abd52eb69954b9921ac71f9b781f6f5f4639181 | |
parent | dda852a0d5c9e684b82cf20380d2b26da1798ecb (diff) | |
download | gitlab-ce-3f72af9994554c66a51cdfb4302e48da0edd043a.tar.gz |
Make notes for merge requests include commit notes and add helpers
-rw-r--r-- | app/contexts/notes/load_context.rb | 2 | ||||
-rw-r--r-- | app/controllers/notes_controller.rb | 5 | ||||
-rw-r--r-- | app/helpers/notes_helper.rb | 5 | ||||
-rw-r--r-- | app/models/note.rb | 6 |
4 files changed, 16 insertions, 2 deletions
diff --git a/app/contexts/notes/load_context.rb b/app/contexts/notes/load_context.rb index f92a780187d..f3949149a06 100644 --- a/app/contexts/notes/load_context.rb +++ b/app/contexts/notes/load_context.rb @@ -13,7 +13,7 @@ module Notes when "issue" project.issues.find(target_id).notes.inc_author.fresh.limit(20) when "merge_request" - project.merge_requests.find(target_id).notes.inc_author.fresh.limit(20) + project.merge_requests.find(target_id).mr_and_commit_notes.inc_author.fresh.limit(20) when "snippet" project.snippets.find(target_id).notes.fresh when "wall" diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index 7f5f5cd2869..d794f368f57 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -7,6 +7,11 @@ class NotesController < ProjectResourceController def index notes + if params[:target_type] == "merge_request" + @mixed_targets = true + @main_target_type = params[:target_type].camelize + end + respond_with(@notes) end diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb index 65389e383d9..3e875023c53 100644 --- a/app/helpers/notes_helper.rb +++ b/app/helpers/notes_helper.rb @@ -7,6 +7,11 @@ module NotesHelper params[:loading_new].present? end + # Helps to distinguish e.g. commit notes in mr notes list + def note_for_main_target?(note) + !@mixed_targets || @main_target_type == note.noteable_type + end + def note_vote_class(note) if note.upvote? "vote upvote" diff --git a/app/models/note.rb b/app/models/note.rb index 65b20fe0b11..ae51e486675 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -49,7 +49,7 @@ class Note < ActiveRecord::Base end def target - if noteable_type == "Commit" + if commit? project.commit(noteable_id) else noteable @@ -82,6 +82,10 @@ class Note < ActiveRecord::Base noteable_type == "Commit" end + def line_note? + line_code.present? + end + def commit_author @commit_author ||= project.users.find_by_email(target.author_email) || |