diff --git a/src/lib/server/gitea.ts b/src/lib/server/gitea.ts index 1b21aa9..3c88e07 100644 --- a/src/lib/server/gitea.ts +++ b/src/lib/server/gitea.ts @@ -2,8 +2,11 @@ export interface GitCommit { message: string; hash: string; shortHash: string; + parentRepo: string; + parentBranch: string; url: string; timestamp: Date; + user: string; } async function getGiteaRepos(fetch: typeof globalThis.fetch) { @@ -41,31 +44,31 @@ async function getRepoCommits(fetch: typeof globalThis.fetch, url: string) { return finalData; } -export async function getLatestCommits(fetch: typeof globalThis.fetch, count: number): GitCommit[] { +export async function getLatestCommits( + fetch: typeof globalThis.fetch, + count: number +): Promise { const repos = await getGiteaRepos(fetch); - let commitList = []; + let commitList: GitCommit[] = []; for (let repo of repos) { - console.log(repo.name); let commits = await getRepoCommits(fetch, repo.url); for (let commit of commits) { - commitList.push(commit); - console.log('pushed'); + console.log(commit); + let newCommit: GitCommit = { + message: commit.commit.message, + hash: commit.sha, + shortHash: commit.sha.substring(0, 8), + 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 + }; + commitList.push(newCommit); } } - commitList.sort((a, b) => new Date(b.created).getTime() - new Date(a.created).getTime()); + commitList.sort((a, b) => b.timestamp.getTime() - a.timestamp.getTime()); - let interfaceCommitList: GitCommit[] = []; - for (let commit of commitList) { - let commitObject: GitCommit = { - message: commit.commit.message, - hash: commit.sha, - shortHash: commit.sha.substring(0, 8), - timestamp: new Date(commit.created), - url: commit.html_url - }; - interfaceCommitList.push(commitObject); - } - - return interfaceCommitList.slice(0, count); + return commitList.slice(0, count); } diff --git a/src/routes/+page.server.ts b/src/routes/+page.server.ts index 9921b74..74dfafa 100644 --- a/src/routes/+page.server.ts +++ b/src/routes/+page.server.ts @@ -19,7 +19,7 @@ export const load: PageServerLoad = () => { const latestBook = getLatestBook(globalThis.fetch, KOMGA_LIBRARY_ID); const contentItems: ContentItem = getContentItems(globalThis.fetch, CHANNEL_ID, BLOG_URL); - const latestCommits: GitCommit = getLatestCommits(globalThis.fetch, 10); + const latestCommits: GitCommit = getLatestCommits(globalThis.fetch, 20); latestSong.catch(() => {}); latestSeries.catch(() => {}); diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 5839937..f0ea02b 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -15,7 +15,7 @@ [VOIDARC INCORPORATED] -
+
-
+
Content
diff --git a/src/routes/Commits.svelte b/src/routes/Commits.svelte index 99c0f44..504a672 100644 --- a/src/routes/Commits.svelte +++ b/src/routes/Commits.svelte @@ -69,7 +69,10 @@ y2={nodePositions[index + 1].y} stroke="currentColor" stroke-width="2" - class="text-ctp-green" + stroke-dasharray={items[index + 1]?.parentRepo != items[index].parentRepo ? '5,4' : '0'} + class={items[index + 1]?.parentRepo == items[index].parentRepo + ? 'text-ctp-green' + : 'text-ctp-surface2'} stroke-linecap="round" /> {/if} @@ -89,17 +92,35 @@ {/each} -