Reject push_branch when working tree has uncommitted changes (#468)

This commit is contained in:
Mateusz Burzyński
2026-03-10 20:16:42 +00:00
committed by pullfrog[bot]
parent f87073fcef
commit 6c9747585f
2 changed files with 18 additions and 0 deletions
+9
View File
@@ -146453,6 +146453,15 @@ function PushBranchTool(ctx) {
throw new Error("Push is disabled. This repository is configured for read-only access.");
}
const branch = branchName || $("git", ["rev-parse", "--abbrev-ref", "HEAD"], { log: false });
const status = $("git", ["status", "--porcelain"], { log: false });
if (status) {
throw new Error(
`push blocked: working tree has uncommitted changes. commit or discard them before pushing.
git status:
${status}`
);
}
const pushUrl = ctx.toolState.pushUrl;
if (!pushUrl) {
throw new Error("pushUrl not set - setupGit must run before push_branch");
+9
View File
@@ -108,6 +108,15 @@ export function PushBranchTool(ctx: ToolContext) {
const branch = branchName || $("git", ["rev-parse", "--abbrev-ref", "HEAD"], { log: false });
// reject push if working tree is dirty — forces agent to commit or discard before pushing
const status = $("git", ["status", "--porcelain"], { log: false });
if (status) {
throw new Error(
`push blocked: working tree has uncommitted changes. commit or discard them before pushing.\n\n` +
`git status:\n${status}`
);
}
// validate push destination matches expected URL
const pushUrl = ctx.toolState.pushUrl;
if (!pushUrl) {