Commit ce559142 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'dm-fix-position-tracer-for-hidden-lines' into 'master'

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

Closes #31339

See merge request !10888
parents e7956954 63d38a30
---
title: Fix commenting on an existing discussion on an unchanged line that is no longer
in the diff
merge_request:
author:
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment