Skip to content

Show the bytes for file changes when the file is not diffable

Thomas Randolph requested to merge tor/feature/show-bytes-for-undiffable into master

What does this MR do?

When a file is not diffable, the UI instead shows the bytes that were modified instead of the count of lines (since git doesn't report a diff in lines for undiffable files).

Caveats

  • Our humanized file sizes fail when the value is below zero. I have opened an MR to fix this problem.
  • Our humanized file sizes require localization text, which assumes the presence of the window object. This means using any of our utilities in a Web Worker (where window is not defined) is not possible - and thus adding these utilities to any file eventually imported into a Worker is not possible. I've opened an MR to fix this problem.
  • One method of creating an undiffable file is changing file encodings, like to UTF-16. Unfortunately, when I change a file to UTF-16, while git does report it as a binary undiffable file, the GitLab UI actually shows a partially corrupted file. In the screenshot this is B# personal (which is # personal in the source file, followed by hundreds of lines).

Screenshots (strongly suggested)

Before After
Decrease in file size before decreaseInBytes
No change in file size Same as above noChange
Increase in file size Same as above increaseInSize

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Edited by Thomas Randolph

Merge request reports