summaryrefslogtreecommitdiff
path: root/app/models/diff_discussion.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-04-30 15:32:09 -0500
committerDouwe Maan <douwe@selenight.nl>2017-05-03 14:47:21 -0500
commitf8fabfcc6ff6be4e20e3cc9353be86b7cf53af47 (patch)
tree15816b09ecdebbd4eb797195b90cb4f46b6819c4 /app/models/diff_discussion.rb
parent185fd98fd4cb8f920558aea3795c4e1774cd39f5 (diff)
downloadgitlab-ce-f8fabfcc6ff6be4e20e3cc9353be86b7cf53af47.tar.gz
Allow commenting on older versions of the diff and comparisons between diff versionsdm-link-discussion-to-outdated-diff
Diffstat (limited to 'app/models/diff_discussion.rb')
-rw-r--r--app/models/diff_discussion.rb20
1 files changed, 19 insertions, 1 deletions
diff --git a/app/models/diff_discussion.rb b/app/models/diff_discussion.rb
index 6a6466b493b..d627fbe327f 100644
--- a/app/models/diff_discussion.rb
+++ b/app/models/diff_discussion.rb
@@ -10,7 +10,6 @@ class DiffDiscussion < Discussion
delegate :position,
:original_position,
- :latest_merge_request_diff,
to: :first_note
@@ -18,6 +17,25 @@ class DiffDiscussion < Discussion
false
end
+ def merge_request_version_params
+ return unless for_merge_request?
+
+ if active?
+ {}
+ else
+ diff_refs = position.diff_refs
+
+ if diff = noteable.merge_request_diff_for(diff_refs)
+ { diff_id: diff.id }
+ elsif diff = noteable.merge_request_diff_for(diff_refs.head_sha)
+ {
+ diff_id: diff.id,
+ start_sha: diff_refs.start_sha
+ }
+ end
+ end
+ end
+
def reply_attributes
super.merge(
original_position: original_position.to_json,