diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2017-04-12 16:11:35 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-04-12 16:11:35 +0800 |
commit | 330292518ec9e5839eb85fbf0ae5887ec8b6b081 (patch) | |
tree | ca7ee936a5c70347dba17a09051443b5fd6e237d /app/helpers/notes_helper.rb | |
parent | eeb89a6010fce509f0cb6735e1ae9dc3cc5336d1 (diff) | |
parent | d59f48987baceb25aa87dc6d87551f68af4bb1ed (diff) | |
download | gitlab-ce-330292518ec9e5839eb85fbf0ae5887ec8b6b081.tar.gz |
Merge remote-tracking branch 'upstream/master' into test-pg-mysql
* upstream/master: (90 commits)
Fixed notebooklab code including file paths
[BB Importer] Save the error trace and the whole raw document
Statisfy Robertcop and Seancop
Update documents according to:
Update licenses.csv via:
Update templates via:
Add foreign key on trigger requests
Added CHANGELOG
Added tests and fixed a typo
Fix typo on the class merge-when-pipeline_succeeds
Axil's review
remove unnecessary line
typo
fix typo
fix links
Remove an unused `cared` scope from Issue and MergeRequest
Remove an unused `Issue.open_for` scope
add topic: authentication
Fix edit button on blame page without repo perms
Don't show 'Copy content' button on text files that are not rendered as text
...
Diffstat (limited to 'app/helpers/notes_helper.rb')
-rw-r--r-- | app/helpers/notes_helper.rb | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb index 5f3d89cf6cb..eab0738a368 100644 --- a/app/helpers/notes_helper.rb +++ b/app/helpers/notes_helper.rb @@ -61,12 +61,23 @@ module NotesHelper end def discussion_diff_path(discussion) - return unless discussion.diff_discussion? + if discussion.for_merge_request? && discussion.diff_discussion? + if discussion.active? + # Without a diff ID, the link always points to the latest diff version + diff_id = nil + elsif merge_request_diff = discussion.latest_merge_request_diff + diff_id = merge_request_diff.id + else + # If the discussion is not active, and we cannot find the latest + # merge request diff for this discussion, we return no path at all. + return + end - if discussion.for_merge_request? && discussion.active? - diffs_namespace_project_merge_request_path(discussion.project.namespace, discussion.project, discussion.noteable, anchor: discussion.line_code) + diffs_namespace_project_merge_request_path(discussion.project.namespace, discussion.project, discussion.noteable, diff_id: diff_id, anchor: discussion.line_code) elsif discussion.for_commit? - namespace_project_commit_path(discussion.project.namespace, discussion.project, discussion.noteable, anchor: discussion.line_code) + anchor = discussion.line_code if discussion.diff_discussion? + + namespace_project_commit_path(discussion.project.namespace, discussion.project, discussion.noteable, anchor: anchor) end end end |