You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: use branch upstream (not default branch) for --branch reviews (#660)
## Summary
- `review --branch`, `tryBranchReview`, `analyze --branch`, and `refine` resolved the merge-base against the repository's default branch (typically `origin/main`). In fork workflows where the current branch's actual upstream (e.g. `upstream/main`) is ahead of `origin/main`, this pulled in commits that were already merged upstream. Each command now prefers `@{upstream}` of the current branch and falls back to `GetDefaultBranch()` only when no upstream is configured.
- Added `git.GetUpstream(repoPath, ref)` (returns the upstream tracking branch via `git rev-parse --abbrev-ref <ref>@{upstream}`, empty on no upstream).
- Replaced the `currentBranch == LocalBranchName(base)` guardrails with `git.IsOnBaseBranch(repoPath, currentBranch, base)`, which generalizes the `origin/` shortcut by verifying `refs/remotes/<base>` exists before stripping the remote prefix — so non-origin remotes are handled and local branches with slashes (e.g. `feature/foo`) are not misclassified.
- New tests: `TestGetUpstream`, `TestIsOnBaseBranch`, and `TestTryBranchReview` cases for the non-origin upstream scenario and for the feature/foo misclassification guard.
Co-authored-by: Phillip Cloud <cpcloud@users.noreply.github.com>
0 commit comments