Improve raw blame parsing logic
What does this MR do and why?
Improve raw blame parsing logic
This change refactors the logic for parsing the raw blame output from gitaly.
We're now using each.with_index.with_object to improve the flow.
We set with_index to fist_line so the index matches the line number. We no longer need to use index + 1 to set the lineno value making it easier to read.
We pass an empty hash into with_object which we use to collect all of the groups. This allows us to lookup the current_group using the hash[commit_sha] and then collecting all of the hash.values at the end.
If the hash[commit_sha] is nil we create the group structure. We've now moved the Commit.new call into this block so it will only be processed for commits that haven't been parsed previously. Prior to this every line would trigger a Commit.new even if we didn't need it.
We've also abstracted the logic for appending the current line to the
group. Previously we called highlighted_lines[line_number - 1] twice
which means for blames with a lot of lines we are iterating through
highlighted_lines twice when we could just store the line. The
abstraction cleans up the readability of the method.