-
Notifications
You must be signed in to change notification settings - Fork 49
Fix support for empty diffs (new, deleted, renamed, binary files). #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
With the latest commit bcc6326, I've finished cleaning up. This PR is ready for final review and merging (commits need to be squashed before merging). |
There are situations where a diff is empty. For example, if a blank file is added a removed. Or if a file is renamed without any changes. This change detects and handles those situations properly. That includes fixing support for modified binary files. Improve test coverage significantly. Fixes #10.
|
||
diff.Hunks = nil | ||
if got, want := diff, test.wantDiff; !reflect.DeepEqual(got, want) { | ||
t.Errorf("%s:\n\ngot: %v\nwant: %v", test.filename, goon.Sdump(got), goon.Sdump(want)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could consider using github.com/d4l3k/messagediff
here instead of printing 2 goons. It might be even more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whatever you think is best; this is just a test dependency so adding dependencies is fine.
@shurcooL does this need to be code reviewed? If so, can you assign it to someone? |
I'm quite confident about this change, but it needs to be reviewed because it's standard practice that we use. I've assigned @slimsag since he has most context (he worked on it in #10 (comment)). |
LGTM |
DO NOT MERGE, this is a WIP PR and there are known TODOs to resolve. Early review (comments, suggestions) is welcome.Edit: Ready for review and merge.There are situations where a diff is empty. For example, if a blank file is added a removed. Or if a file is renamed without any changes. This change detects and handles those situations properly. Edit: Or if the file modified is binary.
Improve test coverage significantly.
TODO
Fixes #10.