Regenerate PR title and body when updating an existing PR#1522
Regenerate PR title and body when updating an existing PR#1522zerone0x wants to merge 1 commit intopingdotgg:mainfrom
Conversation
When an open PR already exists for the current branch, runPrStep previously short-circuited and returned the stale PR metadata without regenerating the title or body. This caused the original PR title to persist across subsequent pushes. Now the code always computes fresh range context and generates new PR content regardless of whether a PR exists. For existing PRs it calls editPullRequest to update the title and body on GitHub, ensuring each push produces an accurate PR description. Fixes pingdotgg#1487 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Closing duplicate — #1519 is the primary fix. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| const existing = yield* findOpenPr(cwd, headContext.headSelectors); | ||
| if (existing) { | ||
| return { | ||
| status: "opened_existing" as const, |
There was a problem hiding this comment.
Content generated against wrong base for retargeted PRs
Medium Severity
When an existing PR is found, baseBranch from resolveBaseBranch is used to compute the range context and generate the new title/body, but the existing PR on GitHub may target a different branch (existing.baseRefName). The readRangeContext diff is computed as baseBranch..HEAD using the locally-resolved base, while the PR's "Files changed" tab on GitHub shows the diff against existing.baseRefName. If someone retargets the PR on GitHub (or local config changes), the regenerated description would describe changes against the wrong base branch. Using existing.baseRefName for content generation when an existing PR is found would keep the description consistent with what GitHub displays.


Summary
Fixes #1487
When an open PR already exists for the current branch,
runPrSteppreviously short-circuited and returned the stale PR metadata (title, body) from GitHub without regenerating it. This caused the original PR title to persist across subsequent pushes — only the commits changed, not the description.The fix removes the early-return path and instead always:
baseBranch..HEAD)generatePrContenteditPullRequestto update its title and body on GitHubThis ensures each push produces an accurate, up-to-date PR description reflecting the current state of the branch.
Test plan
pr editcommandseditPullRequestto the fakeGitHubCliShapein testsopened_existingtests should pass (they verify status and PR number, not title text)Note
Medium Risk
Changes the PR creation flow to mutate existing GitHub PRs via
gh pr edit, which can overwrite titles/bodies and relies on new CLI interactions/temp-file handling.Overview
runPrStepno longer short-circuits when an open PR already exists for the current branch. It now always recomputes the base branch and range context, regenerates PR title/body viageneratePrContent, and updates the existing PR by callinggh pr editwith a temp body file; otherwise it creates a PR as before.Tests update the fake
ghexecutor to acceptpr editand add aneditPullRequesthelper so existing-PR scenarios can exercise the new update path.Written by Cursor Bugbot for commit 5c5b0ea. This will update automatically on new commits. Configure here.
Note
Regenerate and update PR title/body when an existing open PR is found
runPrStepreturned early without changes when an open PR already existed for the current branch.gh pr editbefore returningopened_existingwith the new title.runPrStep.Macroscope summarized 5c5b0ea.