feat: Dont open empty PRs (#782)

This commit is contained in:
Brace Sproul 2025-08-19 17:11:48 -07:00 • committed by GitHub
parent f316685de3
commit 30b0bfb639
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -113,10 +113,27 @@ export async function openPullRequest(
);
}
const repoPath = getRepoAbsolutePath(state.targetRepository);
// First, verify that there are changed files
const gitDiffRes = await sandbox.process.executeCommand(
`git diff --name-only ${state.targetRepository.branch ?? ""}`,
repoPath,
);
if (gitDiffRes.exitCode !== 0 || gitDiffRes.result.trim().length === 0) {
// no changed files
const sandboxDeleted = await deleteSandbox(sandboxSessionId);
return {
...(sandboxDeleted && {
sandboxSessionId: undefined,
dependenciesInstalled: false,
}),
};
}
let branchName = state.branchName;
let updatedTaskPlan: TaskPlan | undefined;
const repoPath = getRepoAbsolutePath(state.targetRepository);
const changedFiles = await getChangedFilesStatus(repoPath, sandbox, config);
if (changedFiles.length > 0) {