added diff info and hover for commits

This commit is contained in:
2026-11-11 16:18:03 +00:00
parent a3a418a037
commit 0b958ae3eb
2 changed files with 53 additions and 23 deletions

View File

@@ -7,6 +7,13 @@ export interface GitCommit {
url: string;
timestamp: Date;
user: string;
diff: Diff;
}
export interface Diff {
additions: number;
deletions: number;
total: number;
}
const CACHE_TTL = 3 * 60 * 60 * 1000;
@@ -68,12 +75,17 @@ async function fetchLatestCommits(
let newCommit: GitCommit = {
message: commit.commit.message,
hash: commit.sha,
shortHash: commit.sha.substring(0, 8),
shortHash: commit.sha.substring(0, 6),
timestamp: new Date(commit.created),
url: commit.html_url,
parentRepo: repo.full_name,
parentBranch: 'main', // I know this is a shit solution
user: commit.commit.author.name
user: commit.commit.author.name,
diff: {
additions: commit.stats.additions,
deletions: commit.stats.deletions,
total: commit.stats.total
}
};
commitList.push(newCommit);
}

View File

@@ -162,35 +162,53 @@
</svg>
<div bind:this={listElement} class=" mr-3 grid grid-flow-row auto-rows-min">
{#each visibleItems as item, index (item.hash)}
{#each visibleItems as commit, index (commit.hash)}
<div class="relative z-10 grid grid-cols-[1.25rem_minmax(0,1fr)] gap-x-3.5 gap-y-2 pb-2">
<!-- Timeline space -->
<div></div>
<div class="min-w-0">
<a href={item.link} class="group block">
{#if visibleItems[index - 1]?.parentRepo != item.parentRepo}
<p class="flex flex-row pt-2">
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
height="20px"
width="20px"
class="pt-1"
fill="#e3e3e3"
><path d="M16.18,13H4V11H16.18l-5.6-5.6L12,4l8,8l-8,8l-1.42-1.4l5.6-5.6Z" /></svg
<div class="block">
{#if visibleItems[index - 1]?.parentRepo != commit.parentRepo}
<p>
<span class="text-ctp-red">
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
height="20px"
width="20px"
class="mr-1 inline-flex items-center whitespace-nowrap"
fill="var(--ctp-peach)"
><path
d="M16.18,13H4V11H16.18l-5.6-5.6L12,4l8,8l-8,8l-1.42-1.4l5.6-5.6Z"
/></svg
><a
class="hover:font-medium hover:underline"
href={'https://git.voidarc.co.uk/' + commit.user}>{commit.user}</a
></span
>
<span class="mx-[1ch] text-ctp-red">{item.user}</span> on
<span class="ml-[1ch] text-ctp-mauve">{item.parentRepo}</span><span
class="text-ctp-yellow">@</span
><span class="text-ctp-green">{item.parentBranch}</span>
on
<a href={'https://git.voidarc.co.uk/' + commit.parentRepo} class="group">
<span class="text-ctp-mauve group-hover:font-medium group-hover:underline"
>{commit.parentRepo}</span
><span class="text-ctp-yellow group-hover:font-medium group-hover:underline"
>@</span
><span class="text-ctp-green group-hover:font-medium group-hover:underline"
>{commit.parentBranch}</span
>
</a>
</p>
{/if}
<div class="flex">
<p class="rounded-md bg-ctp-surface2 px-1">{item.shortHash}</p>
<p class="ml-2 line-clamp-1">{item.message}</p>
</div>
</a>
<a href={commit.url} style="cursor: pointer;" class="group flex justify-items-stretch">
<p
class="rounded-md bg-ctp-surface2 px-1 group-hover:font-bold group-hover:text-ctp-mauve group-hover:underline"
>
{commit.shortHash}
</p>
<p class="ml-2 line-clamp-1 group-hover:font-semibold">{commit.message}</p>
<div class="justify-content-end flex text-align-right flex-1"><div>some</div></div>
</a>
</div>
</div>
</div>
{/each}