How does GitHub refresh a draft pull request's test merge ref after its base branch advances? #214299
Replies: 4 comments
|
yes, this is expected. the pr's base sha and refs/pull/N/merge are snapshots computed by a background job, not live.. a push to the base doesn't refresh them or fire any pull_request event (synchronize is head-only). nothing draft-specific here. there's no documented "refresh merge ref" api, but these work in practice without touching head, draft state or reviews:
if it's just for ci, check out base_ref + the pr head and merge them yourself instead of relying on the merge ref. docs: rest "get a pull request" (mergeability section), "events that trigger workflows → pull_request". |
|
What you're seeing is mostly snapshot behaviour, not a broken merge ref. The docs are quite explicit: when a pull request opens, GitHub records the base as the commit the base branch points to at that moment. A later push to the base branch does not rewrite that recorded base commit in the PR metadata. So
If you need a fresh merge ref without changing the head commit permanently, the practical options are:
All three create an event that forces a new merge calculation. There is no documented "refresh merge ref" API. If you rely on |
|
This appears to be expected behavior, not a draft-specific issue. GitHub handles base updates and PR merge calculations separately. A push to the base branch does not trigger the There is no documented API to force a refresh. Reopening the PR may trigger recalculation, but this isn't a guaranteed solution. For CI, the safest approach is to fetch the latest base and PR head, then merge them locally before running tests. This avoids modifying the PR or its review history. |
|
There is a documented read-only step worth distinguishing from a guaranteed refresh: GitHub's mergeability guide says that That documentation conflicts with the suggestion above that an API read never triggers calculation. However, you already tried reading the PR and observed an old base parent, so I can't conclude that this fixes your case or that a non-null For testing without changing the PR, fetching the live base and head and making an isolated local merge is a separate workaround. It gives you a local result, not a GitHub-generated |
Uh oh!
There was an error while loading. Please reload this page.
🏷️ Discussion Type
Question
Body
An open draft pull request was created before its base branch received another commit. The live base branch reference points to the newer commit, but the pull request's REST base metadata and GraphQL baseRefOid still identify the earlier commit. The test merge reference also has the earlier base commit as its first parent and the unchanged pull request head as its second parent.
An isolated local mergeability check between the current base branch and the unchanged head completes without conflicts. Reading the pull request through the API has not produced an observed refreshed test merge reference.
Is this expected snapshot behavior, or is test merge calculation handled separately? Is there a documented, non-destructive way to obtain an up-to-date test merge reference and a pull_request event bound to the current base, while preserving the head commit, draft status, and review history?
Documentation references explaining the expected behavior and any limitations for draft pull requests would be appreciated. I am seeking clarification, not assuming this is a GitHub bug.
All reactions