diff --git a/entry b/entry index 683f675..eb7ab39 100755 --- a/entry +++ b/entry @@ -146600,6 +146600,7 @@ ${status}` } const refspec = branch === pushDest.remoteBranch ? branch : `${branch}:${pushDest.remoteBranch}`; const pushArgs = force ? ["--force", "-u", pushDest.remoteName, refspec] : ["-u", pushDest.remoteName, refspec]; + await executeLifecycleHook({ event: "prepush", script: ctx.prepushScript }); log.debug(`pushing ${branch} to ${pushDest.remoteName}/${pushDest.remoteBranch}`); if (force) { log.warning(`force pushing - this will overwrite remote history`); @@ -150509,6 +150510,7 @@ var defaultSettings = { modes: [], setupScript: null, postCheckoutScript: null, + prepushScript: null, push: "restricted", shell: "restricted", prApproveEnabled: false, @@ -150547,7 +150549,8 @@ async function fetchRunContext(params) { ...data.settings, modes: data.settings?.modes ?? [], setupScript: data.settings?.setupScript ?? null, - postCheckoutScript: data.settings?.postCheckoutScript ?? null + postCheckoutScript: data.settings?.postCheckoutScript ?? null, + prepushScript: data.settings?.prepushScript ?? null }, apiToken: data.apiToken, oss: data.oss ?? false, @@ -150976,6 +150979,7 @@ async function main() { apiToken: runContext.apiToken, modes: modes2, postCheckoutScript: runContext.repoSettings.postCheckoutScript, + prepushScript: runContext.repoSettings.prepushScript, prApproveEnabled: runContext.repoSettings.prApproveEnabled, modeInstructions: runContext.repoSettings.modeInstructions, toolState, diff --git a/main.ts b/main.ts index 843241d..238f3b5 100644 --- a/main.ts +++ b/main.ts @@ -275,6 +275,7 @@ export async function main(): Promise { apiToken: runContext.apiToken, modes, postCheckoutScript: runContext.repoSettings.postCheckoutScript, + prepushScript: runContext.repoSettings.prepushScript, prApproveEnabled: runContext.repoSettings.prApproveEnabled, modeInstructions: runContext.repoSettings.modeInstructions, toolState, diff --git a/mcp/git.ts b/mcp/git.ts index 5f69eb4..13b9dfc 100644 --- a/mcp/git.ts +++ b/mcp/git.ts @@ -2,6 +2,7 @@ import { regex } from "arkregex"; import { type } from "arktype"; import { log } from "../utils/cli.ts"; import { $git } from "../utils/gitAuth.ts"; +import { executeLifecycleHook } from "../utils/lifecycle.ts"; import { $ } from "../utils/shell.ts"; import type { StoredPushDest, ToolContext } from "./server.ts"; import { execute, tool } from "./shared.ts"; @@ -143,6 +144,8 @@ export function PushBranchTool(ctx: ToolContext) { ? ["--force", "-u", pushDest.remoteName, refspec] : ["-u", pushDest.remoteName, refspec]; + await executeLifecycleHook({ event: "prepush", script: ctx.prepushScript }); + log.debug(`pushing ${branch} to ${pushDest.remoteName}/${pushDest.remoteBranch}`); if (force) { log.warning(`force pushing - this will overwrite remote history`); diff --git a/mcp/server.ts b/mcp/server.ts index 11cd5e7..3e0ca17 100644 --- a/mcp/server.ts +++ b/mcp/server.ts @@ -135,6 +135,7 @@ export interface ToolContext { apiToken: string; modes: Mode[]; postCheckoutScript: string | null; + prepushScript: string | null; prApproveEnabled: boolean; modeInstructions: Record; toolState: ToolState; diff --git a/utils/runContext.ts b/utils/runContext.ts index 40419aa..8aef1ee 100644 --- a/utils/runContext.ts +++ b/utils/runContext.ts @@ -14,6 +14,7 @@ export interface RepoSettings { modes: Mode[]; setupScript: string | null; postCheckoutScript: string | null; + prepushScript: string | null; push: PushPermission; shell: ShellPermission; prApproveEnabled: boolean; @@ -33,6 +34,7 @@ const defaultSettings: RepoSettings = { modes: [], setupScript: null, postCheckoutScript: null, + prepushScript: null, push: "restricted", shell: "restricted", prApproveEnabled: false, @@ -93,6 +95,7 @@ export async function fetchRunContext(params: { modes: data.settings?.modes ?? [], setupScript: data.settings?.setupScript ?? null, postCheckoutScript: data.settings?.postCheckoutScript ?? null, + prepushScript: data.settings?.prepushScript ?? null, }, apiToken: data.apiToken, oss: data.oss ?? false,