Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-08-09 15:11:57 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-08-09 15:11:57 +0300
commit1f229cdc22b5b32989bcff2037d8925c75703671 (patch)
treec92e9dff7737e78d7331518cdf69f90403af09ea /lib/gitlab/diff
parent7a98d989740ec85982cdb6c1d57c8f24270e455e (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/diff')
-rw-r--r--lib/gitlab/diff/parser.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/gitlab/diff/parser.rb b/lib/gitlab/diff/parser.rb
index adb711ca89f..924c28e3db5 100644
--- a/lib/gitlab/diff/parser.rb
+++ b/lib/gitlab/diff/parser.rb
@@ -28,9 +28,11 @@ module Gitlab
if line =~ /^@@ -/
type = "match"
- line_old = line.match(/\-[0-9]*/)[0].to_i.abs rescue 0
- line_new = line.match(/\+[0-9]*/)[0].to_i.abs rescue 0
+ diff_hunk = Gitlab::WordDiff::Segments::DiffHunk.new(line)
+ line_old = diff_hunk.pos_old
+ line_new = diff_hunk.pos_new
+ # not using diff_hunk.first_line? because of defaults
next if line_old <= 1 && line_new <= 1 # top of file
yielder << Gitlab::Diff::Line.new(full_line, type, line_obj_index, line_old, line_new, parent_file: diff_file)