Objective
Fix pushToPullRequestBranchHandler in actions/setup/js/safe_outputs_handlers.cjs to resolve the target repo's checkout path and use it for branch detection and patch generation (mirroring the existing create_pull_request pattern).
Context
Issue #21306: Currently, patch generation always runs in GITHUB_WORKSPACE (workspace root). When the agent commits in a checked-out subdirectory (e.g. ./proxy-frontend for caido/proxy-frontend), those commits are invisible to patch generation → "No commits were found to push."
The create_pull_request handler already does this correctly using findRepoCheckout.
Approach
In pushToPullRequestBranchHandler (after resolveAndValidateRepo and getBaseBranch):
- Set
itemRepo = repoResult.repo (resolved slug, e.g. caido/proxy-frontend)
- Call
findRepoCheckout(itemRepo, undefined, { allowedRepos }). If !checkoutResult.success, return a JSON error: "Repository 'org/repo' not found in workspace. Check out the target repo with a path in checkout."
- Set
repoCwd = checkoutResult.path, repoSlug = itemRepo
- Call
getCurrentBranch(repoCwd) (not getCurrentBranch()) when branch is not provided
- Add
pushPatchOptions.cwd = repoCwd and pushPatchOptions.repoSlug = repoSlug before passing to generateGitPatch
Files to Modify
actions/setup/js/safe_outputs_handlers.cjs — pushToPullRequestBranchHandler function (mirror lines 253–331 for create_pull_request)
Helpers Already Available
findRepoCheckout(repoSlug) → { success, path, repoSlug }
getCurrentBranch(customCwd)
generateGitPatch(branch, baseBranch, { cwd, repoSlug, ... })
Acceptance Criteria
Generated by Plan Command for issue #21306 · ● 147.1K · ◷
Objective
Fix
pushToPullRequestBranchHandlerinactions/setup/js/safe_outputs_handlers.cjsto resolve the target repo's checkout path and use it for branch detection and patch generation (mirroring the existingcreate_pull_requestpattern).Context
Issue #21306: Currently, patch generation always runs in
GITHUB_WORKSPACE(workspace root). When the agent commits in a checked-out subdirectory (e.g../proxy-frontendforcaido/proxy-frontend), those commits are invisible to patch generation → "No commits were found to push."The
create_pull_requesthandler already does this correctly usingfindRepoCheckout.Approach
In
pushToPullRequestBranchHandler(afterresolveAndValidateRepoandgetBaseBranch):itemRepo = repoResult.repo(resolved slug, e.g.caido/proxy-frontend)findRepoCheckout(itemRepo, undefined, { allowedRepos }). If!checkoutResult.success, return a JSON error: "Repository 'org/repo' not found in workspace. Check out the target repo with a path in checkout."repoCwd = checkoutResult.path,repoSlug = itemRepogetCurrentBranch(repoCwd)(notgetCurrentBranch()) when branch is not providedpushPatchOptions.cwd = repoCwdandpushPatchOptions.repoSlug = repoSlugbefore passing togenerateGitPatchFiles to Modify
actions/setup/js/safe_outputs_handlers.cjs—pushToPullRequestBranchHandlerfunction (mirror lines 253–331 forcreate_pull_request)Helpers Already Available
findRepoCheckout(repoSlug)→{ success, path, repoSlug }getCurrentBranch(customCwd)generateGitPatch(branch, baseBranch, { cwd, repoSlug, ... })Acceptance Criteria
findRepoCheckoutis called withitemRepoin the handlergetCurrentBranchreceivesrepoCwdgenerateGitPatchreceivescwdandrepoSlugpointing at the target repo checkoutmake agent-finishpasses (build, test, fmt, lint)Related to Make push_to_pull_request_branch cross-repo #21306