summaryrefslogtreecommitdiff
path: root/lib/gitlab/diff/file.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/diff/file.rb')
-rw-r--r--lib/gitlab/diff/file.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/gitlab/diff/file.rb b/lib/gitlab/diff/file.rb
index 014854da55c..765fb0289a8 100644
--- a/lib/gitlab/diff/file.rb
+++ b/lib/gitlab/diff/file.rb
@@ -76,6 +76,13 @@ module Gitlab
line_code(line) if line
end
+ # Returns the raw diff content up to the given line index
+ def diff_hunk(diff_line)
+ # Adding 2 because of the @@ diff header and Enum#take should consider
+ # an extra line, because we're passing an index.
+ raw_diff.each_line.take(diff_line.index + 2).join
+ end
+
def old_sha
diff_refs&.base_sha
end