Skip to content

Fix manual PR-recreation instructions to match actual git transport (bundle vs patch) - #55510

Merged
dsyme merged 6 commits into
mainfrom
copilot/repo-assistrelease-8120-2026-07-30-4c57e3e83589ea2
Aug 24, 2026
Merged

Fix manual PR-recreation instructions to match actual git transport (bundle vs patch)#55510
dsyme merged 6 commits into
mainfrom
copilot/repo-assistrelease-8120-2026-07-30-4c57e3e83589ea2

Conversation

Copilot AI commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Manually-created PR instructions in fallback issues told users to run git am --3way against a downloaded artifact, but the actual artifact is a git bundle by default (patch-format: bundle), which git am cannot apply — causing every manual recovery attempt to fail with patch does not apply.

Root cause

  • manifest_protection_push_failed_fallback.md and manifest_protection_push_to_pr_fallback.md (used when protected files block an automated push or apply) hardcoded git am --3way instructions regardless of transport.
  • These are the only two fallback templates that weren't already transport-aware — the generic (non manifest-protection) push-failed fallback already branched correctly on bundle vs. patch.

Changes

  • New shared helpers in create_pull_request_helpers.cjs:

    • buildManualBranchRecoveryCommands — recreates a new local branch and pushes it, used before opening a PR by hand.
    • buildManualBranchApplyCommands — applies changes onto an existing remote branch (e.g. an already-open PR).

    Both pick bundle-based (git fetch into a temp ref → git update-ref/git reset --hard) or patch-based (git am --3way) commands based on hasBundleFile.

  • create_pull_request.cjs: protected-files push-failed fallback now detects the actual artifact type and renders the matching instructions.

  • push_to_pull_request_branch.cjs: protected-files apply fallback does the same for the existing-branch case.

  • Templates: replaced hardcoded patch/git am command blocks with a single {apply_instructions} placeholder filled in by the caller; also genericized "patch" wording to "changes"/"artifact" since it may be a bundle.

Example — bundle transport now correctly renders:

gh run download 12345 -n agent -D /tmp/agent-12345
git fetch /tmp/agent-12345/aw-feature.bundle refs/heads/feature:refs/bundles/create-pr-feature-abcd1234
git update-ref refs/heads/feature refs/bundles/create-pr-feature-abcd1234
git checkout feature
git reset --hard
git update-ref -d refs/bundles/create-pr-feature-abcd1234

instead of the previously-emitted (and non-functional) git am --3way /tmp/agent-12345/aw-feature.bundle.


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

@github-actions

Copy link
Copy Markdown
Contributor

Hey @Copilot 👋 — thanks for taking on the patch generation fix! This is well-scoped and the problem statement in the body is clear.

Since this is still a draft with no code changes yet, a couple of things to watch for as you develop:

Looking forward to the fix — this addresses a real blocker for users applying patches manually.

Generated by ✅ Contribution Check · copilot · auto · 54.3 AIC · ⌖ 4.04 AIC · ⊞ 9.3K ·

…ansport

Co-authored-by: dsyme <7204669+dsyme@users.noreply.github.com>
Copilot AI changed the title [WIP] [repo-assist] Fix incorrect instructions for manual PR creation Fix manual PR-recreation instructions to match actual git transport (bundle vs patch) Aug 24, 2026
Copilot AI requested a review from dsyme August 24, 2026 21:08
@dsyme
dsyme marked this pull request as ready for review August 24, 2026 21:21
Copilot AI balanced review requested due to automatic review settings August 24, 2026 21:21

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

Updates protected-file fallback issues to generate recovery commands matching bundle or patch transport.

Changes:

  • Adds shared bundle/patch recovery-command builders.
  • Integrates transport-aware instructions into both PR fallback flows.
  • Adds tests for each transport.
Show a summary per file
File Description
actions/setup/md/manifest_protection_push_to_pr_fallback.md Uses generated apply instructions.
actions/setup/md/manifest_protection_push_failed_fallback.md Uses generated recovery instructions.
actions/setup/js/push_to_pull_request_branch.test.cjs Tests both transports.
actions/setup/js/push_to_pull_request_branch.cjs Selects instructions from the artifact type.
actions/setup/js/create_pull_request.test.cjs Tests push-failure recovery instructions.
actions/setup/js/create_pull_request.cjs Renders transport-aware recovery commands.
actions/setup/js/create_pull_request_helpers.cjs Adds shared command builders.

Review details

Suppressed comments (2)

actions/setup/js/create_pull_request_helpers.cjs:385

  • This hardcodes refs/heads/${branchName}, although the existing apply path must resolve a sole alternate branch ref or HEAD when that ref is absent (push_to_pull_request_branch.cjs:1044-1092), and the repository has an explicit HEAD-only bundle test. A protected-files fallback can occur before that resolution, so users receive another non-functional fetch command for these supported bundles. Generate the same git bundle list-heads/HEAD fallback in the manual instructions and test it with an actual bundle.
      `git fetch /tmp/agent-${runId}/${artifactFileName} refs/heads/${branchName}:refs/bundles/manual-apply`,

actions/setup/js/create_pull_request_helpers.cjs:388

  • The handler supports updating an explicitly configured fork head and computes its distinct push target (push_to_pull_request_branch.cjs:735-761), but this helper always tells the user to push origin. In a normal checkout, origin is the base repository, so the command either fails or updates a same-named base-repo branch instead of the existing fork PR. Pass the resolved head-repository remote/URL into this helper and use it for both fetch and push instructions.
      `git push origin ${branchName}`,
  • Files reviewed: 7/7 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment thread actions/setup/js/create_pull_request_helpers.cjs Outdated
Comment thread actions/setup/js/create_pull_request_helpers.cjs Outdated
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

gh-aw-pr-sous-chef
@copilot PR Sous Chef triage: this PR still needs forward progress before maintainer investigation is likely to be productive.

Please do one focused follow-up pass:

I also attempted a branch refresh for this PR in this run.

Run: https://github.com/github/gh-aw/actions/runs/32781466813

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

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

Copilot AI commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

gh-aw-pr-sous-chef
@copilot PR Sous Chef triage: this PR still needs forward progress before maintainer investigation is likely to be productive.
...

Addressed in 002186c. The manual apply instructions now reset the local branch from FETCH_HEAD and push HEAD:refs/heads/<branch>, which works for fork-head URL remotes; recovery coverage now also executes a real HEAD-only bundle path. Fixed the prior lint-js formatting failure locally (make lint-cjs passes) and ran final make agent-report-progress successfully.

Copilot AI requested a review from gh-aw-bot August 24, 2026 22:18
@dsyme
dsyme merged commit 38803d8 into main Aug 24, 2026
3 checks passed
@dsyme
dsyme deleted the copilot/repo-assistrelease-8120-2026-07-30-4c57e3e83589ea2 branch August 24, 2026 22:58
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.87.5

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Instructions for how to manually create a PR are wrong

4 participants