@@ -12,6 +12,64 @@ import {
1212} from "./diffRendering" ;
1313
1414describe ( "getRenderablePatch" , ( ) => {
15+ it ( "retains explicit binary markers without classifying other hunkless files as binary" , ( ) => {
16+ const patch = [
17+ "diff --git a/added.png b/added.png" ,
18+ "new file mode 100644" ,
19+ "index 0000000..1234567" ,
20+ "Binary files /dev/null and b/added.png differ" ,
21+ 'diff --git "a/old image.png" "b/new image.png"' ,
22+ "similarity index 50%" ,
23+ "rename from old image.png" ,
24+ "rename to new image.png" ,
25+ 'Binary files "a/old image.png" and "b/new image.png" differ' ,
26+ "diff --git a/deleted.png b/deleted.png" ,
27+ "deleted file mode 100644" ,
28+ "Binary files a/deleted.png and /dev/null differ" ,
29+ "diff --git a/payload.bin b/payload.bin" ,
30+ "GIT binary patch" ,
31+ "literal 3" ,
32+ "KcmZQzWC8#H2mk;8" ,
33+ "diff --git a/empty.txt b/empty.txt" ,
34+ "new file mode 100644" ,
35+ "index 0000000..e69de29" ,
36+ "diff --git a/old.txt b/new.txt" ,
37+ "similarity index 100%" ,
38+ "rename from old.txt" ,
39+ "rename to new.txt" ,
40+ "diff --git a/omitted.txt b/omitted.txt" ,
41+ "index 1111111..2222222 100644" ,
42+ "diff --git a/lfs.png b/lfs.png" ,
43+ "new file mode 100644" ,
44+ "--- /dev/null" ,
45+ "+++ b/lfs.png" ,
46+ "@@ -0,0 +1,3 @@" ,
47+ "+version https://git-lfs.github.com/spec/v1" ,
48+ "+oid sha256:1234567890" ,
49+ "+size 123" ,
50+ "diff --git a/marker.txt b/marker.txt" ,
51+ "--- a/marker.txt" ,
52+ "+++ b/marker.txt" ,
53+ "@@ -1 +1 @@" ,
54+ "-Binary files a/fake.png and b/fake.png differ" ,
55+ "+GIT binary patch" ,
56+ "" ,
57+ ] . join ( "\n" ) ;
58+ for ( const ignoreWhitespace of [ false , true ] ) {
59+ const parsed = getRenderablePatch ( patch , "pr-page-1" , {
60+ ignoreWhitespace,
61+ compactPartialHunkOffsets : true ,
62+ } ) ;
63+ expect ( parsed ?. kind ) . toBe ( "files" ) ;
64+ if ( parsed ?. kind !== "files" ) return ;
65+ expect ( parsed . files ) . toHaveLength ( 9 ) ;
66+ expect ( parsed . files . slice ( 0 , 7 ) . every ( ( file ) => file . hunks . length === 0 ) ) . toBe ( true ) ;
67+ expect ( parsed . binaryFileKeys ) . toEqual (
68+ new Set ( parsed . files . slice ( 0 , 4 ) . map ( buildFileDiffIdentityKey ) ) ,
69+ ) ;
70+ }
71+ } ) ;
72+
1573 it ( "hides indentation changes around inserted JSX without moving review lines" , ( ) => {
1674 const patch = [
1775 "diff --git a/item.tsx b/item.tsx" ,
0 commit comments