Skip to content

Use explicit PR head baseline for fork PR branch updates - #56119

Open
dsyme with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-push-to-pull-request-branch
Open

Use explicit PR head baseline for fork PR branch updates#56119
dsyme with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-push-to-pull-request-branch

Conversation

Copilot AI commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

push_to_pull_request_branch could not generate incremental patches for fork PRs checked out via refs/pull/<N>/head, because it expected origin/<head.ref> to exist in the base repository. In same-named branch cases, that fallback could also select the wrong base repo ref.

  • Record PR checkout baseline

    • Capture the fetched PR head ref/SHA during PR-context checkout.
    • Export it as GH_AW_PR_HEAD_BASE_* for later safe-output patch generation.
  • Use explicit incremental base

    • Teach patch and bundle generation to prefer the recorded PR-head baseline over origin/<branch>.
    • Keep the existing origin/<branch> path as a same-repo/backward-compatible fallback.
  • Avoid misleading fork guidance

    • Update missing-baseline errors to describe the PR checkout baseline requirement instead of recommending checkout.fetch for fork branches.
  • Regression coverage

    • Covers fork PRs without origin/<branch>.
    • Covers fork PRs where the base repo has a same-named branch.
    • Covers safe-output persistence and bundle generation from the recorded PR head.
await generateGitPatch("feature/native_versions", "main", {
  mode: "incremental",
  incrementalBaseRef: "refs/remotes/origin/pr-head",
  incrementalBaseSha: prHeadSha,
});

Co-authored-by: dsyme <7204669+dsyme@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix push_to_pull_request_branch for fork PRs Use explicit PR head baseline for fork PR branch updates Aug 26, 2026
Copilot AI requested a review from dsyme August 26, 2026 20:05
@dsyme
dsyme marked this pull request as ready for review August 26, 2026 22:19
Copilot AI balanced review requested due to automatic review settings August 26, 2026 22:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an explicit PR-head baseline so incremental safe-output patches and bundles work correctly for fork PRs.

Changes:

  • Exports PR checkout baseline metadata.
  • Prefers the recorded baseline during patch and bundle generation.
  • Adds fork and same-named branch regression tests.
Show a summary per file
File Description
actions/setup/js/checkout_pr_branch.cjs Records PR-head baseline metadata.
actions/setup/js/checkout_pr_branch.test.cjs Tests baseline exports.
actions/setup/js/safe_outputs_handlers.cjs Applies baseline to push artifacts.
actions/setup/js/safe_outputs_handlers.test.cjs Tests safe-output persistence.
actions/setup/js/generate_git_patch.cjs Supports explicit incremental patch bases.
actions/setup/js/generate_git_patch.test.cjs Covers fork and name-collision patches.
actions/setup/js/generate_git_bundle.cjs Supports explicit incremental bundle bases.
actions/setup/js/generate_git_bundle.test.cjs Covers fork bundle generation.

Review details

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 8/8 changed files
  • Comments generated: 2
  • Review effort level: Balanced

return;
}
core.exportVariable("GH_AW_PR_HEAD_BASE_BRANCH", branchName);
core.exportVariable("GH_AW_PR_HEAD_BASE_SHA", baseSha);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in cd10... — now resolving HEAD^{commit} after checkout and exporting that as GH_AW_PR_HEAD_BASE_SHA instead of the payload/API head.sha.

Comment on lines +58 to +60
if (!baselineBranch || baselineBranch !== branchName || (!baselineRef && !baselineSha)) {
return null;
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b997284 — the checkout step now exports GH_AW_PR_HEAD_BASE_PR_NUMBER alongside the baseline, and resolvePRHeadBaselineForPush rejects the recorded baseline unless it matches the effective target PR number (explicit pull_request_number, or the triggering PR/issue context).

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot PR #56119 is ready for forward progress.

Generated by 👨‍🍳 PR Sous Chef · pi · gpt54 · 9.03 AIC · ⌖ 8.03 AIC · ⊞ 8.7K ·
Comment /souschef to run again

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

Category: bug; risk: medium; score: 54/100 (impact 25/50, urgency 16/30, quality 13/20); recommended action: batch_review; CI: pending/unknown; review signal: 3 reviews, 1 issue comment.

Generated by 🔧 PR Triage Agent · copilot · mai10 · 13.5 AIC · ⌖ 2.44 AIC · ⊞ 16.6K ·

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

push_to_pull_request_branch cannot update fork PRs after PR-context checkout

4 participants