Skip to content

[plan] Fix push_to_pull_request_branch MCP handler to generate patches from target repo directory #28373

@github-actions

Description

@github-actions

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):

  1. Set itemRepo = repoResult.repo (resolved slug, e.g. caido/proxy-frontend)
  2. 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."
  3. Set repoCwd = checkoutResult.path, repoSlug = itemRepo
  4. Call getCurrentBranch(repoCwd) (not getCurrentBranch()) when branch is not provided
  5. Add pushPatchOptions.cwd = repoCwd and pushPatchOptions.repoSlug = repoSlug before passing to generateGitPatch

Files to Modify

  • actions/setup/js/safe_outputs_handlers.cjspushToPullRequestBranchHandler 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

  • findRepoCheckout is called with itemRepo in the handler
  • getCurrentBranch receives repoCwd
  • generateGitPatch receives cwd and repoSlug pointing at the target repo checkout
  • If target repo is not found in workspace, a clear error is returned
  • make agent-finish passes (build, test, fmt, lint)
    Related to Make push_to_pull_request_branch cross-repo #21306

Generated by Plan Command for issue #21306 · ● 147.1K ·

  • expires on Apr 26, 2026, 11:51 PM UTC

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions