feat: turborepo monorepo scaffold and provisioning
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
29
lib/gitea.ts
29
lib/gitea.ts
@@ -163,4 +163,33 @@ export async function verifyWebhookSignature(
|
||||
return expected === signature;
|
||||
}
|
||||
|
||||
/**
|
||||
* Push a single file to a repo via the Gitea contents API.
|
||||
* Creates the file if it doesn't exist; updates it if it does.
|
||||
*/
|
||||
export async function giteaPushFile(
|
||||
owner: string,
|
||||
repo: string,
|
||||
path: string,
|
||||
content: string,
|
||||
message: string,
|
||||
branch = 'main',
|
||||
): Promise<void> {
|
||||
const encoded = Buffer.from(content).toString('base64');
|
||||
|
||||
// Check if file already exists to get its SHA (required for updates)
|
||||
let sha: string | undefined;
|
||||
try {
|
||||
const existing = await giteaFetch(`/repos/${owner}/${repo}/contents/${path}?ref=${branch}`);
|
||||
sha = (existing as any)?.sha;
|
||||
} catch {
|
||||
// File doesn't exist — create it
|
||||
}
|
||||
|
||||
await giteaFetch(`/repos/${owner}/${repo}/contents/${path}`, {
|
||||
method: sha ? 'PUT' : 'POST',
|
||||
body: JSON.stringify({ message, content: encoded, branch, ...(sha ? { sha } : {}) }),
|
||||
});
|
||||
}
|
||||
|
||||
export const GITEA_ADMIN_USER_EXPORT = GITEA_ADMIN_USER;
|
||||
|
||||
Reference in New Issue
Block a user