19 lines
562 B
TypeScript
19 lines
562 B
TypeScript
const BASE_URL = import.meta.env.VITE_API_URL ?? '';
|
|
|
|
export interface GitCommit {
|
|
hash: string;
|
|
shortHash: string;
|
|
author: string;
|
|
date: string;
|
|
subject: string;
|
|
files: string[];
|
|
}
|
|
|
|
export async function getGitLog(path?: string, limit = 20): Promise<GitCommit[]> {
|
|
const params = new URLSearchParams({ limit: String(limit) });
|
|
if (path) params.set('path', path);
|
|
const res = await fetch(`${BASE_URL}/api/git/log?${params}`);
|
|
if (!res.ok) throw new Error(`Failed to get git log: ${res.statusText}`);
|
|
return res.json();
|
|
}
|