Skip to content
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

Add basic support for binary diffs #46

Merged
merged 3 commits into from May 27, 2020
Merged

Add basic support for binary diffs #46

merged 3 commits into from May 27, 2020

Conversation

eseliger
Copy link
Member

@eseliger eseliger commented May 26, 2020

This adds support for parsing the cases in ./diff/testdata/sample_binary_inline.diff correctly.

@eseliger eseliger added the bug label May 26, 2020
@codecov
Copy link

codecov bot commented May 26, 2020

Codecov Report

Merging #46 into master will increase coverage by 0.18%.
The diff coverage is 62.50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #46      +/-   ##
==========================================
+ Coverage   28.12%   28.31%   +0.18%     
==========================================
  Files           5        5              
  Lines        1152     1155       +3     
==========================================
+ Hits          324      327       +3     
+ Misses        784      783       -1     
- Partials       44       45       +1     
Impacted Files Coverage Δ
diff/parse.go 81.04% <62.50%> (+0.18%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8c3ae63...75d7ce2. Read the comment docs.

Copy link
Member

@keegancsmith keegancsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. What happened previously in this code when diffing binary files? Do you need any special settings for git for this to work?

diff/parse.go Outdated
@@ -341,7 +341,7 @@ func (r *FileDiffReader) ReadExtendedHeaders() ([]string, error) {
func handleEmpty(fd *FileDiff) (wasEmpty bool) {
var err error
switch {
case (len(fd.Extended) == 3 || len(fd.Extended) == 4 && strings.HasPrefix(fd.Extended[3], "Binary files ")) &&
case (len(fd.Extended) == 3 || len(fd.Extended) == 4 && strings.HasPrefix(fd.Extended[3], "Binary files ") || len(fd.Extended) > 4 && strings.HasPrefix(fd.Extended[3], "GIT binary patch")) &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like this conditional is big enough and repeated enough to be factored out?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made it smaller and replaced the common len check by a variable

@eseliger
Copy link
Member Author

Previously the file paths would be empty strings, now they are properly populated

@eseliger eseliger merged commit f935979 into master May 27, 2020
@eseliger eseliger deleted the es/binary-diffs branch May 27, 2020 11:49
@eseliger eseliger mentioned this pull request May 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants