Skip to content
Snippets Groups Projects
Commit 63d38a30 authored by Douwe Maan's avatar Douwe Maan
Browse files

Fix commenting on an existing discussion on an unchanged line that is no longer in the diff

parent 1005389f
No related branches found
No related tags found
No related merge requests found
---
title: Fix commenting on an existing discussion on an unchanged line that is no longer
in the diff
merge_request:
author:
Loading
Loading
@@ -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,
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -569,13 +569,8 @@ describe Gitlab::Diff::PositionTracer, lib: true do
# 1 1 BB
# 2 2 A
 
it "returns the new position" do
expect_new_position(
old_path: file_name,
new_path: new_file_name,
old_line: old_position.new_line,
new_line: old_position.new_line
)
it "returns nil since the line doesn't exist in the new diffs anymore" do
expect(subject).to be_nil
end
end
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment