diff --git a/web/src/lib/components/repo/CommitView.svelte b/web/src/lib/components/repo/CommitView.svelte index ce5be247f..9579c6937 100644 --- a/web/src/lib/components/repo/CommitView.svelte +++ b/web/src/lib/components/repo/CommitView.svelte @@ -15,6 +15,8 @@ import { FULL_HASH_RE } from "$lib/api/repo"; import CommitHeader from "$lib/components/repo/CommitHeader.svelte"; import DiffView from "$lib/components/repo/DiffView.svelte"; + import type { CodeViewFile } from "$lib/components/repo/DiffCodeView.svelte"; + import { blobHref } from "$lib/components/repo/urls"; import type { DiffStyle } from "$lib/components/repo/pierre"; import TabPanel from "$lib/components/ui/TabPanel.svelte"; import type { CommitStatuses } from "$lib/api/commitStatuses"; @@ -58,6 +60,12 @@ const base = $derived(`/${ownerHandle}/${repoName}`); + const blobUrl = $derived((file: CodeViewFile) => + file.kind === "deleted" + ? undefined + : blobHref(ownerHandle, repoName, commit.hash, file.name) + ); + let deferred = $state<{ spec?: RepoDiffSpec; diff?: RepoDiff; error?: string }>({}); $effect(() => { const spec = mirror.pendingSpec; @@ -115,6 +123,7 @@ diff={mirrorDiff} error={mirrorError} loading={mirrorLoading} + {blobUrl} {diffStyle} styleHref={(style) => `?diff=${style}`} {downloadUrls} diff --git a/web/src/lib/components/repo/DiffCodeView.svelte b/web/src/lib/components/repo/DiffCodeView.svelte index fc8e25a22..68ef7275a 100644 --- a/web/src/lib/components/repo/DiffCodeView.svelte +++ b/web/src/lib/components/repo/DiffCodeView.svelte @@ -31,7 +31,7 @@ interface Props { files: CodeViewFile[]; entry: (key: string) => DiffEntry | undefined; - blobUrl?: (key: string) => string | undefined; + blobUrl?: (file: CodeViewFile) => string | undefined; headerActions?: Snippet<[string]>; diffStyle?: DiffStyle; wrap?: boolean; @@ -88,7 +88,7 @@ openState, noteState, note: noteOf(file), - blobUrl: blobUrl?.(file.key), + blobUrl: blobUrl?.(file), headerActions, onToggle: () => onSetOpen?.(file.key, !(openState.get(file.key) ?? true)) } diff --git a/web/src/lib/components/repo/DiffFiles.svelte b/web/src/lib/components/repo/DiffFiles.svelte index 8d7df9ff1..c0aa87467 100644 --- a/web/src/lib/components/repo/DiffFiles.svelte +++ b/web/src/lib/components/repo/DiffFiles.svelte @@ -15,6 +15,7 @@ interface Props { deps: RepoDiffDeps; diff: RepoDiff; + blobUrl?: (file: CodeViewFile) => string | undefined; diffStyle?: DiffStyle; wrap?: boolean; isOpen?: (key: string) => boolean; @@ -30,6 +31,7 @@ let { deps, diff, + blobUrl, diffStyle = "unified", wrap = false, isOpen = () => true, @@ -161,6 +163,7 @@ bind:this={view} files={viewFiles} entry={(key) => entries.get(key)} + {blobUrl} {diffStyle} {wrap} {isOpen} diff --git a/web/src/lib/components/repo/DiffView.svelte b/web/src/lib/components/repo/DiffView.svelte index 11274a865..7257e940b 100644 --- a/web/src/lib/components/repo/DiffView.svelte +++ b/web/src/lib/components/repo/DiffView.svelte @@ -16,6 +16,7 @@ import DiffFileTree from "$lib/components/repo/DiffFileTree.svelte"; import DiffStatPill from "$lib/components/repo/DiffStatPill.svelte"; import DiffFiles from "$lib/components/repo/DiffFiles.svelte"; + import type { CodeViewFile } from "$lib/components/repo/DiffCodeView.svelte"; import type { DiffStyle } from "$lib/components/repo/pierre"; import type { PatchStream } from "$lib/api/patchStream"; import type { RepoDiff, RepoDiffDeps } from "$lib/api/repoDiff"; @@ -33,6 +34,7 @@ diff?: RepoDiff; error?: string; loading?: boolean; + blobUrl?: (file: CodeViewFile) => string | undefined; /** the style to open with, and the live one when the route owns it */ diffStyle?: DiffStyle; /** set when the route persists the style in its url: the buttons become @@ -52,6 +54,7 @@ diff, error, loading = false, + blobUrl, diffStyle: routeStyle = "unified", styleHref, wrap = $bindable(false), @@ -283,6 +286,7 @@