diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-04-24 11:13:08 -0500 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-04-24 11:17:15 -0500 |
commit | 63d38a303b47d73b3d97a2c8f8ffb5271d39c13d (patch) | |
tree | ef2df9a863308202b72c11ba609a1d5f449c2bc5 /lib/gitlab/diff | |
parent | 1005389f70070245092c1ae5f3f9b10b8e7c102e (diff) | |
download | gitlab-ce-63d38a303b47d73b3d97a2c8f8ffb5271d39c13d.tar.gz |
Fix commenting on an existing discussion on an unchanged line that is no longer in the diff
Diffstat (limited to 'lib/gitlab/diff')
-rw-r--r-- | lib/gitlab/diff/position_tracer.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/gitlab/diff/position_tracer.rb b/lib/gitlab/diff/position_tracer.rb index 4d04f867268..c7542a8fabc 100644 --- a/lib/gitlab/diff/position_tracer.rb +++ b/lib/gitlab/diff/position_tracer.rb @@ -82,7 +82,7 @@ module Gitlab file_diff, old_line, new_line = results - Position.new( + new_position = Position.new( old_path: file_diff.old_path, new_path: file_diff.new_path, head_sha: new_diff_refs.head_sha, @@ -91,6 +91,13 @@ module Gitlab old_line: old_line, new_line: new_line ) + + # If a position is found, but is not actually contained in the diff, for example + # because it was an unchanged line in the context of a change that was undone, + # we cannot return this as a successful trace. + return unless new_position.diff_line(repository) + + new_position end private |