diff --git a/CHANGELOG b/CHANGELOG index 7e9a447a8f6f229ff009b028b4cb02477bea77e7..507830b575bbf59a59bbe1e4ad700013b910186a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,7 @@ v 8.7.0 (unreleased) - Add links to CI setup documentation from project settings and builds pages - Implement 'Groups View' as an option for dashboard preferences !3379 (Elias W.) - Implement 'TODOs View' as an option for dashboard preferences !3379 (Elias W.) + - Gracefully handle notes on deleted commits in merge requests (Stan Hu) v 8.6.2 (unreleased) - Comments on confidential issues don't show up in activity feed to non-members diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb index 53c543c28c5d20e9352fb2f105d06f9d606f13dc..698f90cb27ae9df09d6f22e9e5465e39cd0ed406 100644 --- a/app/helpers/notes_helper.rb +++ b/app/helpers/notes_helper.rb @@ -5,8 +5,10 @@ def note_for_main_target?(note) end def note_target_fields(note) - hidden_field_tag(:target_type, note.noteable.class.name.underscore) + - hidden_field_tag(:target_id, note.noteable.id) + if note.noteable + hidden_field_tag(:target_type, note.noteable.class.name.underscore) + + hidden_field_tag(:target_id, note.noteable.id) + end end def note_editable?(note) diff --git a/app/views/projects/notes/discussions/_commit.html.haml b/app/views/projects/notes/discussions/_commit.html.haml index 3da2f2060b8845de60243c7b01bb09c52315c948..f67ec8db942c33380e20a05d4cbe344a9c206c5b 100644 --- a/app/views/projects/notes/discussions/_commit.html.haml +++ b/app/views/projects/notes/discussions/_commit.html.haml @@ -1,4 +1,6 @@ - note = discussion_notes.first +- commit = note.noteable +- commit_description = commit ? 'commit' : 'a deleted commit' .discussion.js-toggle-container{ class: note.discussion_id } .discussion-header .discussion-actions @@ -7,8 +9,9 @@ Show/hide discussion %div = link_to_member(@project, note.author, avatar: false) - started a discussion on commit - = link_to(note.noteable.short_id, namespace_project_commit_path(note.project.namespace, note.project, note.noteable), class: 'monospace') + %p started a discussion on #{commit_description} + - if commit + = link_to(commit.short_id, namespace_project_commit_path(note.project.namespace, note.project, note.noteable), class: 'monospace') .last-update.hide.js-toggle-content - last_note = discussion_notes.last last updated by