yeonjuan / parse-git-diff

parse git diff
MIT License
28 stars 3 forks source link

add missing eof line support #11

Closed zmully closed 1 year ago

zmully commented 1 year ago

Adds support for missing eof marker in git diffs. Without this, the parser will only parse the diff up to the first instance of this marker in the diff.

@yeonjuan I don't actually have any use for this in the parsed output, but discovered this issue when I was experimenting with your library. I'm also not sure if this is the only git diff line that uses the \ character, the git docs are rather sparse on this matter.

yeonjuan commented 1 year ago

HI, @zmully Thanks for fixing it!

I don't actually have any use for this in the parsed output, but discovered this issue when I was experimenting with your library. I'm also not sure if this is the only git diff line that uses the \ character, the git docs are rather sparse on this matter.

After a quick check of the git source, it seems that the "\" character is always followed by a "No newline at end of file" message. But I thinks it would be great if we use general type value such as "Message" for the handling other messages we might miss.

{
   type: "Message",
   content: "No newline at end of file"
}
zmully commented 1 year ago

Thanks @yeonjuan for the quick review and feedback! I've updated the PR with your feedback and added the missing README section I didn't catch the first time around. Thanks for putting together this library, it is super useful, and helped me put together an internal tool to parse out stringified JSON (like usually seen in IAM policy declarations) in diffs and redisplay the changes in a format that makes reviewing changes easier and less error prone.