Skip to content

Introduce whitespace_only attribute to the diff viewer

Marc Shaw requested to merge add_whitespace_only_change_to_viewer into master

What does this MR do and why?

We have introduced a new feature flag to switch between the different git whitespace options.

When we have no changes except whitespace changes, then we should show this to the user.

To remove logic from the frontend, we introduce a new state in the viewer, for when it is a whitespace only change.

#390666 (comment 1301956724)

Testing instructions:

  • Turn on feature flag: Feature.enable(:add_ignore_all_white_spaces)
  • Add and commit this a file called TESTFILE with the following contents into a repository:
Leading whitespace with tab 1
Leading whitespace with space 2
Trailing whitespace with tab 3
Trailing whitespace with space 4
  • Make a new branch. Eg. whitespace-test

  • Replace TESTFILE with the following contents (Note the leading/trailing whitespace changes as well):

            Leading whitespace with tab 1
     Leading whitespace with space 2
    Trailing whitespace with tab 3	
    Trailing whitespace with space 4 
  • Create a new MR from this branch.

  • Look at the diff with Show Whitespace changes both on and off, look at the network tab for the diffs_batch request and check for the viewer under a diff file and ensure the whitespace only is true.

  • Load another MR and check that whitespace only is false for another diff.

Edited by Marc Shaw

Merge request reports