UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

63 lines (62 loc) 2.12 kB
import { r as runCommandWithTimeout, t as runCommandBuffered } from "./exec-BIE-3oLG.js"; import { t as createCommandError } from "./command-error-D_Bz4MBL.js"; //#region src/infra/git-exec.ts const GIT_TIMEOUT_MS = 12e4; function withForegroundGitMaintenance(argv) { return argv[0] === "git" ? [ "git", "-c", "maintenance.autoDetach=false", "-c", "gc.autoDetach=false", ...argv.slice(1) ] : argv; } async function executeGitCommand(cwd, args, options = {}) { const timeoutMs = options.timeoutMs ?? 12e4; const argv = [ "git", "-C", cwd, ...args ]; return { ...await runCommandWithTimeout(options.killProcessTree ? withForegroundGitMaintenance(argv) : argv, { ...options, timeoutMs }), timeoutMs }; } function createGitCommandError(command, result) { const error = createCommandError(command, result, { timeoutMs: result.timeoutMs ?? 12e4 }); if (result.termination === "timeout") error.message += "\nCheck repository access and disk space."; return error; } async function requireGitCommand(cwd, args, options = {}) { const result = await executeGitCommand(cwd, args, options); if (result.code !== 0) throw createGitCommandError(`git ${args.join(" ")}`, result); return result.stdout.trim(); } async function requireGitCommandRaw(cwd, args, options = {}) { const result = await executeGitCommand(cwd, args, options); if (result.code !== 0) throw createGitCommandError(`git ${args.join(" ")}`, result); return result.stdout; } async function requireGitCommandBuffer(cwd, args, options = {}) { const result = await runCommandBuffered([ "git", "-C", cwd, ...args ], { timeoutMs: GIT_TIMEOUT_MS, env: options.env, input: options.input, ...options.maxOutputBytes !== void 0 ? { maxOutputBytes: options.maxOutputBytes } : {} }); if (result.code !== 0) throw createGitCommandError(`git ${args.join(" ")}`, result); return result.stdout; } //#endregion export { requireGitCommandBuffer as a, requireGitCommand as i, createGitCommandError as n, requireGitCommandRaw as o, executeGitCommand as r, withForegroundGitMaintenance as s, GIT_TIMEOUT_MS as t };