Method: Gitlab::Diff::Rendered::Notebook::DiffFileHelper#source_line_from_block

Defined in:
lib/gitlab/diff/rendered/notebook/diff_file_helper.rb

#source_line_from_block(transformed_line, transformed_blocks) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
# File 'lib/gitlab/diff/rendered/notebook/diff_file_helper.rb', line 83

def source_line_from_block(transformed_line, transformed_blocks)
  # Blocks are the lines returned from the library and are a hash with {text:, source_line:}
  # Blocks source_line are 0 indexed
  return 0 if transformed_blocks.empty?

  line_in_source = transformed_blocks[transformed_line - 1][:source_line]

  return 0 unless line_in_source.present?

  line_in_source
end