diff --git a/src/components/repo.tsx b/src/components/repo.tsx index e35730f..99e0b10 100644 --- a/src/components/repo.tsx +++ b/src/components/repo.tsx @@ -3,13 +3,16 @@ import DOMPurify from 'dompurify'; import { ChevronRight, Circle, + Columns2, FileText, + FoldVertical, Folder, Minimize2, PanelLeftClose, PanelLeftOpen, PanelRightClose, PanelRightOpen, + UnfoldVertical, ChevronLeft, } from 'lucide-solid'; import { marked } from 'marked'; @@ -523,6 +526,20 @@ const parseDiffFiles = (patch: string): DiffFile[] => { const pushCurrent = () => { if (!current) return; + const hasRenderableDiff = current.lines.some( + (line) => + line.startsWith('@@') || + line.startsWith('Binary files ') || + line.startsWith('new file mode ') || + line.startsWith('deleted file mode ') || + line.startsWith('old mode ') || + line.startsWith('similarity index ') || + line.startsWith('rename from '), + ); + if (!hasRenderableDiff && current.additions === 0 && current.deletions === 0) { + current = null; + return; + } files.push({ path: current.path, text: current.lines.join('\n'), @@ -559,26 +576,91 @@ const parseDiffFiles = (patch: string): DiffFile[] => { export const DiffView: Component<{ patch: string; maxHeight?: string; wrap?: boolean }> = (props) => { const files = createMemo(() => parseDiffFiles(props.patch)); + const stats = createMemo(() => totalDiffStats(files())); + const [expanded, setExpanded] = createSignal(false); + const previewLimit = 5; + const visibleFiles = createMemo(() => files().slice(0, previewLimit)); + const hiddenFiles = createMemo(() => files().slice(previewLimit)); return (