johnandersen777.bsky.social/knotless
git that lives in your Atmosphere account
Forked from chadtmiller.com/knotless
0
0
<script lang="ts">
import type { CommitAuthorView, CommitView } from '#lib/lexicons/dev/knotless/defs.ts';
import { ago, day, urlPath, whenCommitted } from '#lib/format.ts';
import Time from '#lib/atoms/Time.svelte';
import CommitAuthor from './CommitAuthor.svelte';
/**
* Who wrote a commit and when it was committed, as `alice committed 2
* hours ago`; and, as a rebase or a squash keeps when it was written,
* when that was another day, or who committed it when someone else did:
* `alice authored on Oct 2 and bob committed on Oct 5`, which a list
* cuts to who wrote it and when it was committed. Each part `mute` when
* told.
*/
let { commit: c, mute = false }: { commit: CommitView; mute?: boolean } = $props();
const by = $derived(c.committer);
const earlier = $derived(day(c.date) !== day(whenCommitted(c)));
const on = (t: string) => ago(t, 'on ');
</script>
{#snippet who(a: CommitAuthorView)}{#if a.actor}<a href="/{urlPath(a.actor.handle)}"
><b>{a.name}</b></a
>{:else}<b>{a.name}</b>{/if}{/snippet}
<CommitAuthor commit={c} />
{#snippet when(t: string)}<Time at={t} show={on} />{/snippet}
<span class="committed" class:mute
>{#if earlier || by}<span class="committed-long"
>{#if earlier}{'authored '}{@render when(
c.date
)}{:else}authored{/if}{' and '}{#if by}{@render who(
by
)}{' committed'}{:else}committed{/if}{' '}{@render when(whenCommitted(c))}</span
><span class="committed-short">{'committed '}{@render when(whenCommitted(c))}</span
>{:else}{'committed '}{@render when(whenCommitted(c))}{/if}</span
>