feat: add project git init api (#16383)

This commit is contained in:
Shoubhit Dash
2026-03-07 01:09:50 +05:30
committed by GitHub
parent 95385eb652
commit d6e0f47361
6 changed files with 280 additions and 21 deletions

View File

@@ -347,6 +347,21 @@ export namespace Project {
return fromRow(row)
}
export async function initGit(input: { directory: string; project: Info }) {
if (input.project.vcs === "git") return input.project
if (!which("git")) throw new Error("Git is not installed")
const result = await git(["init", "--quiet"], {
cwd: input.directory,
})
if (result.exitCode !== 0) {
const text = result.stderr.toString().trim() || result.text().trim()
throw new Error(text || "Failed to initialize git repository")
}
return (await fromDirectory(input.directory)).project
}
export const update = fn(
z.object({
projectID: z.string(),