Fix parsing unified diff hunks with "No newline at end of file" markers.

Review Request #12578 — Created Sept. 4, 2022 and submitted — Latest diff uploaded

Information

DiffX
master

Reviewers

When parsing unified diff hunks, a "No newline at end of file" marker
found within content would be seen as garbage, causing a
MalformedHunkError to be raised. This could easily manifest when
generating stats for metadata sections.

The parser now handles these lines within a hunk. They're counted as
processed, but are otherwise ignored.

Unit tests pass.

Tested this with some repro cases we were sent. All parsing passed.

Diff Revision 1 (Latest)

Commits

First Last Summary ID Author
Fix parsing unified diff hunks with "No newline at end of file" markers.
When parsing unified diff hunks, a "No newline at end of file" marker found within content would be seen as garbage, causing a `MalformedHunkError` to be raised. This could easily manifest when generating stats for metadata sections. The parser now handles these lines within a hunk. They're counted as processed, but are otherwise ignored.
ab0d8d1345f58424e41032ddb5f05e6ffe3f01c9 Christian Hammond
python/pydiffx/tests/test_utils_unified_diffs.py
python/pydiffx/utils/unified_diffs.py
Loading...