Skip to content

Expand diff to entire file

(Frontend issue: #56011)

Users want to review the entire file (with diffs) during code review of a merge request, and not just a small snippet. How do we make that easy? Probably by expanding the diff of a file in a merge request to view the entire file with the diff.

Why do we need this? What problems / pain points are we solving?

When doing code review, people want to expand a file to see context. We currently have controls to expand in both directions, that allows a good number of lines to show more context. And that is important, because it solves the problem of the person wanting to see the immediate context, i.e. neighboring code, the entire function/method, etc. This is the first scenario.

But there is another use case (second scenario), which is that the person wants to see the entire file right away. For example, if the person wants to see the name of the class, or maybe they are looking for some definitions near the top of the file, they want to be able to quickly scroll up to the top of the file. Currently, this requires a person to click many times in order to do so. This is a pain point we want to solve with this feature.

Proposal

Add a button to expand the diff to show the entire file

Out of scope: We are not doing any smart expanding to a certain dynamic point in the file. Expand to the end of the current function, code block, etc. This may be a future improvement if necessary.

Design

image

  • Replace the edit button with an icon button to save space. Tooltip Edit file. Opens in the same tab. Icon: pencil.
  • Replace "View file @ CommitID" button with an icon button. Tooltip View file @ <CommitID>. Opens in a new tab. Icon: external-link.
  • The "Show full file" button will toggle to "Show changes only". Clicking on the button brings the diff to the top of the page (similar to clicking on the file in the file browser).

What business outcomes will the success of this feature have? How can we measure that?

This is being implemented based on customer feedback, that during code review people regularly want to be able to view more than just the immediately changed lines of code. Measuring how frequently this option used will not yield significant useful information and therefore will not be measured.

Links / references

Reviewboard does this nicely in two ways:

  • expand until next indentation marker (class, method, function)
  • expand full file

Try reviewboard here

Edited by Jeethu Karthik