Skip to content

Commit

Permalink
fix: handle binary diff without extended header (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
yeonjuan committed Aug 9, 2023
1 parent 62d8908 commit 396f040
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/__fixtures__/changed-binary-file
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
diff --git a/file1 b/file1
index 21be030..9443748 100644
Binary files a/file1 and b/file1 differ
Binary files a/file1 and b/file1 differ
diff --git a/file1 b/file2
index 21be030..9443748 100644
Binary files a/file1 and b/file2 differ
11 changes: 11 additions & 0 deletions src/__tests__/__snapshots__/changed-binary-file.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ exports[`changed binary file parse \`changed-binary-file\` 1`] = `
"path": "file1",
"type": "ChangedFile",
},
{
"chunks": [
{
"pathAfter": "file2",
"pathBefore": "file1",
"type": "BinaryFilesChunk",
},
],
"path": "file2",
"type": "ChangedFile",
},
],
"type": "GitDiff",
}
Expand Down
2 changes: 1 addition & 1 deletion src/parse-git-diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function parseFileChange(ctx: Context): AnyFileChange | undefined {
} else if (
chunks.length &&
chunks[0].type === 'BinaryFilesChunk' &&
chunks[0].pathAfter === chunks[0].pathBefore
chunks[0].pathAfter
) {
return {
type: FileType.Changed,
Expand Down

0 comments on commit 396f040

Please sign in to comment.