commit menu looking sick asl

This commit is contained in:
2026-11-10 17:11:44 +00:00
parent 38ce5f3554
commit aceee88132
4 changed files with 52 additions and 28 deletions

View File

@@ -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<GitCommit[]> {
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);
}