Skip to content

PR preview counts commits merged to main after the PR branched as the PR's own #683

Open

Description

@goosewobbler

Summary

In advisory standing-pr mode, the PR preview limits the version analysis to the PR's own commits by passing baseRef = pull_request.base.sha (packages/release/src/preview/preview.ts, prBaseSha). That SHA is where the PR last synced with its base, not the base tip. The workflow checks out GitHub's merge ref (refs/pull/N/merge), whose first parent is the base tip. So base.sha..HEAD also contains every commit merged into main since the PR branched, and the preview lists them as changes this PR adds.

A PR that has just merged main in looks right, which makes this easy to miss. The longer a PR goes without syncing, the more of other PRs' changes its preview shows.

Evidence: #672

#673 showed the same thing on a smaller scale: after #682 merged, its preview listed #682's commit, because #673 hadn't merged main since.

Impact

  • The changelog section shows other PRs' changes.
  • The "After merge — predicted release" table can show an escalation this PR doesn't cause. A feat or breaking commit that landed on main after the branch point is counted as this PR's. (ci: skip CodeQL, release preview and title checks on the standing release PR #672 didn't show one only because the standing PR is already at 0.42.0.)
  • Consumers get the same behaviour. templates/workflows/release-preview.yml uses the default checkout, which is the merge ref.

Also affected: the post-release preview refresh (opt-in)

refreshFeederPreviews (ci.prPreview.refreshAfterRelease) calls runPreview for each open PR from the release job's checkout of main, passing pr.baseSha from the REST API. runPreview doesn't check out the PR. So the range is pr.baseSha..main: main's commits since the PR branched, and none of the PR's own. For #672 today that would be 10 commits, none of them #672's. I found this by reading the code. This repo doesn't enable the option, so I haven't seen it live.

Suggested fix

  • Event path: scope to the base branch tip, not pull_request.base.sha. On the merge ref that's HEAD^1. More generally, git rev-parse origin/<pull_request.base.ref> works with fetch-depth: 0. <base tip>..HEAD lists only the PR's commits whether the checkout is the merge ref or the PR head.
  • Refresh path: the analysis needs the PR's tree, for example a worktree of refs/pull/N/merge scoped from its first parent. Otherwise the refresh shouldn't recompute the version analysis.
  • Test: a preview test where the base branch gains a feat commit after the PR branches, asserting that only the PR's own commit appears and the predicted bump doesn't escalate.

Activity

  1. added this to the 0.43.0 milestone on Oct 23, 2026
  2. goosewobbler commented on Oct 24, 2026

    @goosewobbler
    OwnerAuthor

    Decision (maintainer): option B for the post-release refresh. The refresh stops recomputing previews from the release job's checkout. It marks each open feeder PR's preview as stale ("main has moved; this preview updates on the PR's next push") instead. The fix for the event path is unchanged: count only commits after the base branch's tip.

    This supersedes #797: the refresh will no longer call runPreview, so its early return can't skip feeder PRs. Carry #797's lesson over:

    • Pick the PRs to mark from the forge's list of open PRs, never from the job's event payload. The refresh runs inside a standing-PR publish job, whose event is the standing PR's.
    • Test through refreshFeederPreviews under a standing-PR closed event payload, asserting that a feeder PR's preview is marked stale.
  3. added
    status:agent-readyDefined and ready for an autonomous (AFK) agent to pick up
    and removed
    status:agent-readyDefined and ready for an autonomous (AFK) agent to pick up
    on Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:wipWork in progresstype:bugSomething isn't working

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions