Skip to content

Commit 396f040

Browse files
authored
fix: handle binary diff without extended header (#23)
1 parent 62d8908 commit 396f040

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

src/__fixtures__/changed-binary-file

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
diff --git a/file1 b/file1
22
index 21be030..9443748 100644
3-
Binary files a/file1 and b/file1 differ
3+
Binary files a/file1 and b/file1 differ
4+
diff --git a/file1 b/file2
5+
index 21be030..9443748 100644
6+
Binary files a/file1 and b/file2 differ

src/__tests__/__snapshots__/changed-binary-file.test.ts.snap

+11
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ exports[`changed binary file parse \`changed-binary-file\` 1`] = `
1414
"path": "file1",
1515
"type": "ChangedFile",
1616
},
17+
{
18+
"chunks": [
19+
{
20+
"pathAfter": "file2",
21+
"pathBefore": "file1",
22+
"type": "BinaryFilesChunk",
23+
},
24+
],
25+
"path": "file2",
26+
"type": "ChangedFile",
27+
},
1728
],
1829
"type": "GitDiff",
1930
}

src/parse-git-diff.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ function parseFileChange(ctx: Context): AnyFileChange | undefined {
117117
} else if (
118118
chunks.length &&
119119
chunks[0].type === 'BinaryFilesChunk' &&
120-
chunks[0].pathAfter === chunks[0].pathBefore
120+
chunks[0].pathAfter
121121
) {
122122
return {
123123
type: FileType.Changed,

0 commit comments

Comments
 (0)