Reject push_branch when working tree has uncommitted changes (#468)
This commit is contained in:
committed by
pullfrog[bot]
parent
f87073fcef
commit
6c9747585f
@@ -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");
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user