Save lines_removed and lines_added to database
Problem to solve
Git's diff
function calculates "lines deleted" and "lines added" for every commit. Currently GitLab performs those diffs by either 1) asking Gitaly to do it or 2) using a Ruby class. Those options are fine for performing a single diff. But those require too much processing when you want to diff many commits once, like for internal metrics and some analytics features where code complexity is of interest.
Proposal
Store deleted_lines
and added_lines
in the merge_request_metrics
table (where diff_size
, modified_paths_size
, and commits_count
are already stored).
Note: There is some early support for this idea.
Technical notes
- To see existing usage in the app, look for
deleted_lines
andadded_lines
in Ruby anddeletedLines
andaddedLines
in JS.