23 lines
574 B
TypeScript
23 lines
574 B
TypeScript
|
import api from "@/lib/gitea";
|
||
|
import { GitEntry, APIError } from "gitea-js";
|
||
|
|
||
|
export async function retrieveTreeStructure(
|
||
|
owner: string,
|
||
|
repo: string,
|
||
|
sha: string
|
||
|
): Promise<GitEntry[]> {
|
||
|
try {
|
||
|
const response = await api.repos.getTree(owner, repo, sha, {
|
||
|
recursive: true,
|
||
|
});
|
||
|
return response.data.tree || [];
|
||
|
} catch (error) {
|
||
|
if ((error as APIError).message) {
|
||
|
console.error("Gitea API Error", error);
|
||
|
} else {
|
||
|
console.error("Unexpected Error", error);
|
||
|
}
|
||
|
throw new Error("Failed to retrieve tree structure");
|
||
|
}
|
||
|
}
|