fix(web): keep a file-to-symlink type change from crashing the diff view (#11075)

Co-authored-by: shivam <[email protected]>
This commit is contained in:
Igor Makowskiandshivam authored and GitHub committed 2026-09-18 17:12:17 +05:30
1 parent 52e4b44293
commit 9ea9c3d5d2
5 files changed
+87 -8

No files matched your search

@@ -23,11 +23,22 @@ function toGitStatus(file: FileDiffMetadata): GitStatus {
}
}
/** Maps parsed diff files to tree entries, keeping the diff's own order. */
/**
* Maps parsed diff files to tree entries, keeping the diff's own order. A path
* appears once: a type change (regular file to symlink) is a deletion plus an
* addition of the same path, and the tree shows the surviving file as modified.
*/
export function diffFileTreeEntries(
files: ReadonlyArray<FileDiffMetadata>,
): ReadonlyArray<DiffFileTreeEntry> {
return files.map((file) => ({ path: resolveFileDiffPath(file), status: toGitStatus(file) }));
const statusByPath = new Map<string, GitStatus>();
for (const file of files) {
const path = resolveFileDiffPath(file);
const status = toGitStatus(file);
const previous = statusByPath.get(path);
statusByPath.set(path, previous === undefined || previous === status ? status : "modified");
}
return [...statusByPath].map(([path, status]) => ({ path, status }));
}
/**