oldBin := !strings.HasPrefix(http.DetectContentType(oldData), "text/")
newBin := !strings.HasPrefix(http.DetectContentType(newData), "text/")
if oldBin && newBin {
- return "Binary files differ, cannot show diff", nil
+ return fmt.Sprintf("Binary files differ (%d -> %d bytes), "+
+ "cannot show diff", len(oldData), len(newData)), nil
}
if oldBin {
- oldData = []byte("<binary content>\n")
+ oldData = []byte(fmt.Sprintf("<binary content, %d bytes>\n",
+ len(oldData)))
}
if newBin {
- newData = []byte("<binary content>\n")
+ newData = []byte(fmt.Sprintf("<binary content, %d bytes>\n",
+ len(newData)))
}
// TODO: difflib shows empty context lines at the end of the file
Group: group,
Gid: gid,
},
- DataDiff: "Binary files differ, cannot show diff",
+ DataDiff: "Binary files differ (3 -> 4 bytes), cannot show diff",
},
},
},
Gid: gid,
},
DataDiff: `@@ -1,2 +1,2 @@
--<binary content>
+-<binary content, 3 bytes>
+content
`,
},
DataDiff: `@@ -1,2 +1,2 @@
-content
-+<binary content>
++<binary content, 4 bytes>
`,
},