@posthog/agent
Version:
TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog
42 lines (40 loc) • 1.33 kB
JavaScript
/**
* Commits (and optionally pushes) any staged changes according to the step configuration.
* Returns true if a commit was created.
*/
async function finalizeStepGitActions(context, step, options) {
if (!step.commit) {
return false;
}
const { gitManager, logger } = context;
const hasStagedChanges = await gitManager.hasStagedChanges();
if (!hasStagedChanges && !options.allowEmptyCommit) {
logger.debug("No staged changes to commit for step", { stepId: step.id });
return false;
}
try {
await gitManager.commitChanges(options.commitMessage);
logger.info("Committed changes for step", {
stepId: step.id,
message: options.commitMessage,
});
}
catch (error) {
logger.error("Failed to commit changes for step", {
stepId: step.id,
error: error instanceof Error ? error.message : String(error),
});
throw error;
}
if (step.push) {
const branchName = await gitManager.getCurrentBranch();
await gitManager.pushBranch(branchName);
logger.info("Pushed branch after step", {
stepId: step.id,
branch: branchName,
});
}
return true;
}
export { finalizeStepGitActions };
//# sourceMappingURL=utils.js.map