From 9ff5529c9f93009d467b57a047054f57ea542998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C5=ABdolfs=20O=C5=A1i=C5=86=C5=A1?= Date: Wed, 30 Sep 2026 15:15:22 +0200 Subject: [PATCH] Move revision description helpers into lib The commit-list check was written twice, and revision titles and the commit group collapse rule were untested inside components. --- src/components/Changes.svelte | 11 +-- src/components/PatchActivityItem.svelte | 17 +--- src/components/Revision.svelte | 54 +++-------- src/lib/revisionDescription.ts | 73 +++++++++++++++ src/views/repo/Patch.svelte | 8 +- tests/unit/revisionDescription.test.ts | 118 ++++++++++++++++++++++++ 6 files changed, 206 insertions(+), 75 deletions(-) create mode 100644 src/lib/revisionDescription.ts create mode 100644 tests/unit/revisionDescription.test.ts diff --git a/src/components/Changes.svelte b/src/components/Changes.svelte index c37c673e6..585f9faff 100644 --- a/src/components/Changes.svelte +++ b/src/components/Changes.svelte @@ -25,6 +25,7 @@ getDiffText, } from "@app/lib/invoke"; import { anchorOf, commentCountsByPath } from "@app/lib/pierreComments"; + import { isCommitListDescription } from "@app/lib/revisionDescription"; import { useShortcuts } from "@app/lib/shortcuts.svelte"; import { pluralize } from "@app/lib/utils"; @@ -329,16 +330,6 @@ } }); - function isCommitListDescription(description: string, commits: Commit[]) { - if (commits.length === 0) return false; - const chunks = description - .split("\n") - .map(l => l.trim()) - .filter(l => l.length > 0); - if (chunks.length !== commits.length) return false; - const summaries = new Set(commits.map(c => c.summary.trim())); - return chunks.every(line => summaries.has(line)); - } const revisionDescription = $derived( revision.description.slice(-1)[0]?.body?.trim() ?? "", ); diff --git a/src/components/PatchActivityItem.svelte b/src/components/PatchActivityItem.svelte index b21e6098d..df86d8780 100644 --- a/src/components/PatchActivityItem.svelte +++ b/src/components/PatchActivityItem.svelte @@ -4,22 +4,6 @@ import type { FlattenedPatchOperation } from "@app/lib/patchTimeline"; export type { FlattenedPatchOperation }; - - export function splitDescription(text: string): { - subject?: string; - body?: string; - } { - const trimmed = text.trim(); - if (!trimmed) return {}; - const idx = trimmed.indexOf("\n"); - if (idx === -1) return { subject: trimmed }; - const subject = trimmed.slice(0, idx).trim(); - const body = trimmed.slice(idx + 1).trim(); - return { - subject: subject || undefined, - body: body || undefined, - }; - }