Skip to content

Commit 701d475

Browse files
author
RMacfarlane
committed
Correctly handle undefined patch for empty files, fixes #1372
1 parent d5dd2ad commit 701d475

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/common/diffHunk.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,18 @@ export async function parseDiff(reviews: IRawFileChange[], repository: Repositor
260260
const gitChangeType = getGitChangeType(review.status);
261261

262262
if (!review.patch) {
263-
fileChanges.push(new SlimFileChange(review.blob_url, gitChangeType, review.filename));
264-
continue;
263+
// Patch is not returned if
264+
// 1. File has only been renamed
265+
// 2. The diff is "too large"
266+
// 3. The file is empty
267+
// 4. Unknown other reasons
268+
// Treat case 3 as something that should be opened locally, offer to open everything else on GitHub
269+
if (review.status === 'renamed' || review.additions || review.changes || review.deletions) {
270+
fileChanges.push(new SlimFileChange(review.blob_url, gitChangeType, review.filename));
271+
continue;
272+
} else {
273+
review.patch = '';
274+
}
265275
}
266276

267277
let originalFileExist = false;

0 commit comments

Comments
 (0)