Skip to content

Bug: newly added empty files still show a -0 diff count #399

@WarningImHack3r

Description

@WarningImHack3r

Prerequisites

Describe the issue

A very "aesthetic" "issue" that could also be a feature request, but fits better in the bug category.

Parsing works fine with empty files added in a PR, but:

  • the -0 is present despite not being relevant at all. the +0 is arguably a bit weird too, but still better than what GitHub does: showing "whitespace-only change" with no diff count.
  • no diff is shown at all. this is not a real bug as there is actually nothing to show, but having a diff header with nothing inside it looks off. maybe adding a File added with no content or similar would help?

Showcase:
diff of an empty added file

Note

The counterpart fix(es) could maybe be applied to deleted empty files too

Reproduction

Use FileDiff#render on the output of parsePatchFiles with this data:

--- /dev/null
+++ whatever.js

OR

diff --git a/whatever.js b/whatever.js
new file mode 100644
index 000000000000..e69de29bb2d1

What browser(s) are you seeing the problem on?

Chrome

What version of @pierre/diffs are you using?

1.0.11

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions