~ knotless Search/
↑↓ move↵ open⇧↵ all results

johnandersen777.bsky.social/knotless

git that lives in your Atmosphere account

Forked from chadtmiller.com/knotless

0
0
54 lines · 1.9 KB Raw History
<script lang="ts">
	import type * as getCommit from '#lib/lexicons/dev/knotless/getCommit.ts';
	import { ask } from '#lib/data.ts';
	import { itemHref, repoHref, subject, urlPath } from '#lib/format.ts';
	import Committed from '#lib/molecules/Committed.svelte';
	import Icon from '#lib/atoms/Icon.svelte';
	import Sha from '#lib/atoms/Sha.svelte';
	import Diff from '#lib/organisms/Diff.svelte';
	import RepoPage from '#lib/templates/RepoPage.svelte';
	let { data } = $props();
	const ch = $derived(data.change);
	const r = $derived(data.repo);
	const c = $derived(ch.commit);
	const cut = $derived(c.message.indexOf('\n'));
	const title = $derived(cut < 0 ? c.message : c.message.slice(0, cut));
	const rest = $derived(cut < 0 ? '' : c.message.slice(cut + 1).trim());
	/** The rest of its files' rows, a few files at a time. */
	const more = (paths: string[]) =>
		ask<typeof getCommit.main>('dev.knotless.getCommit', {
			repo: r.uri,
			sha: c.sha,
			paths
		}).then((a) => a.files);
	/** Where its files are after it: at the commit, each on its page there. */
	const source = $derived({
		repo: r.uri,
		rev: c.sha,
		view: (path: string) => repoHref(data.authority, r.name, `/blob/${c.sha}/${urlPath(path)}`)
	});
</script>

<RepoPage repo={r} tab="code" title="{subject(c.message)} · {r.name}">
	<div class="box">
		<div class="commit-msg">
			<h2>{title}</h2>
			{#if rest}<pre>{rest}</pre>{/if}
		</div>
		<div class="boxhead boxfoot">
			<Committed commit={c} mute />
			{#if c.pull}<a
					class="from mute"
					href={itemHref(repoHref(data.authority, r.name), c.pull.uri)}
					title={c.pull.title}><Icon name="merge" />Pull</a
				>{/if}
			<span class="end mute"
				>{#each c.parents as p, i (p.sha)}{i ? ' parent ' : 'parent '}<Sha
						sha={p.sha}
						href={repoHref(data.authority, r.name, `/commit/${p.sha}`)}
					/>{/each}{c.parents.length ? ' commit ' : 'commit '}<Sha sha={c.sha} /></span
			>
		</div>
	</div>
	<Diff files={ch.files} {more} {source} />
</RepoPage>