Skip to content

Commit 0566396

Browse files
committed
fix: don't show 'binary file' placeholder for empty files
A file with no content changes (empty added file, rename without content change, deleted empty file) has no patch in the GitHub files API, and the diff placeholder treated every patchless file as binary or too large — showing 'Binary file or file too large to display' for an empty file. Distinguish the benign cases by status and git's empty-blob SHA, and keep the binary/too-large message for the rest.
1 parent e378806 commit 0566396

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/browser/components/pr-review.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,15 @@ const DiffPanel = memo(function DiffPanel() {
12991299
) : (
13001300
<div className="p-4 text-sm text-muted-foreground text-center flex-1 flex items-center justify-center">
13011301
{!currentFile.patch
1302-
? "Binary file or file too large to display"
1302+
? currentFile.status === "removed"
1303+
? "File deleted"
1304+
: currentFile.status === "renamed"
1305+
? "File renamed without changes"
1306+
: currentFile.sha ===
1307+
"e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"
1308+
? // Git's empty-blob SHA: the file exists but has no content
1309+
"Empty file"
1310+
: "Binary file or file too large to display"
13031311
: "No changes to display"}
13041312
</div>
13051313
)}

0 commit comments

Comments
 (0)