Fix PR creation from origin-based worktrees - #3218
Conversation
|
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)
Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: PR range uses local base
- In runPrStep, the base branch for readRangeContext is now resolved to the remote tracking ref (e.g. origin/main) using resolvePrimaryRemoteName, with a fallback to the local ref if the remote-qualified ref is unavailable, aligning PR range computation with the status/divergence path.
Or push these changes by commenting:
@cursor push f3d8594d49
You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 1d107bd. Configure here.
ApprovabilityVerdict: Approved Straightforward bug fix that ensures PR content is generated against the remote base branch rather than a potentially stale local base. Changes are well-scoped with comprehensive test coverage and backwards-compatible schema additions. You can customize Macroscope's approvability policy. Learn more. |
…ettings-imports Fix PR creation from origin-based worktrees (pingdotgg#3218)


Summary
Validation
vp test packages/contracts/src/git.test.ts apps/server/src/vcs/GitVcsDriverCore.test.ts apps/server/src/server.test.tsvp checkvp run typecheckNote
Medium Risk
Touches PR generation, worktree bootstrap, and base-branch resolution in git workflows; behavior changes are targeted but affect stacked git actions and thread worktree creation.
Overview
Fixes PR creation and generated PR content when a feature branch was cut from a fetched remote default branch while the local default ref is still behind
origin.GitManageraddsresolveBaseRangeRefso auto-generated PR titles/bodies diff against the remote-tracking commit for the resolved base branch (e.g.origin/main’s SHA), not a stale localmain. A regression test covers remote-ahead / local-behind worktrees withgh-merge-baseset.Worktree bootstrap threads optional
baseRefNamethroughVcsCreateWorktreeInput,ws.ts, andcreateWorktree, which persistsbranch.<newRefName>.gh-merge-baseso later PR flows know the intended base.GitVcsDriverCoreprefers an existing remote-tracking branch over a same-named local branch when resolving base candidates, and tests assert correct merge-base config and zero ahead counts for origin-fetched worktrees.Reviewed by Cursor Bugbot for commit e030293. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix PR creation from origin-based worktrees by using remote tracking commit as range base
resolveBaseRangeRefhelper inGitManager.tsthat resolves the base branch to the remote tracking commit SHA when a primary remote exists, falling back to the local branch name.runStackedActionto use this resolved ref when callingreadRangeContext, so PR content excludes commits already on the remote base.branch.<newRefName>.gh-merge-basein git config when creating a worktree with abaseRefName, enabling correct ancestry tracking for origin-based worktrees.resolveUpstreamRefNameFromCandidatesto prefer remote-prefixed refs over local branches when both exist.baseRefName, which triggers the new git config write; upstream ref resolution now prefers remote over local when both are present.Macroscope summarized e030293.