peppa/packages/runner/src/git.ts
Асель 3ab408eb70 PEP-57: CI for factory projects — act_runner, template workflow, connect CI
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 14:19:11 +05:00

27 lines
1.1 KiB
TypeScript

// git as peppa-bot: the per-repo `peppa` credential helper answers for the Gitea host.
import { execFile } from "node:child_process";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { promisify } from "node:util";
import { loadEnv, peppaRoot } from "@peppa/shared";
export const run = promisify(execFile);
export function credentialHelper(): string {
return `!${peppaRoot(resolve(dirname(fileURLToPath(import.meta.url)), "../../.."))}/packages/cli/bin/git-credential-peppa`;
}
export function git(cwd: string, ...args: string[]) {
// The peppa helper answers for the Gitea host with the bot token; nothing else is consulted.
return run("git", ["-c", "credential.helper=", "-c", `credential.helper=${credentialHelper()}`, ...args], {
cwd,
env: { ...process.env, GIT_TERMINAL_PROMPT: "0" },
});
}
/** Clone URL of the shared project template (override for tests). */
export function templateRepoUrl(override?: string): string {
const env = loadEnv();
return override ?? process.env.PEPPA_TEMPLATE_URL ?? `${env.GITEA_URL}/${env.GITEA_TEMPLATE_REPO}.git`;
}