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
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 the
default branch only when no upstream is configured.
- Add git.GetUpstream(repoPath, ref). Returns ("", nil) when no
@{upstream} is set, the resolved name when the ref exists locally,
and ("", *UpstreamMissingError) when the upstream is configured but
the referenced ref does not resolve (e.g. never fetched). Callers in
analyze/review/refine surface UpstreamMissingError to the user so
fork workflows don't silently analyze the wrong commit range; the
post-commit hook path (tryBranchReview) treats it as "skip" since
hooks must never block commits.
- Add git.IsOnBaseBranch(repoPath, currentBranch, base), replacing the
"currentBranch == LocalBranchName(base)" check. The new helper only
strips a slash-containing base as a remote-tracking ref when
refs/remotes/<base> resolves, refs/heads/<base> does not, and the
prefix matches one of the repository's configured remote names.
That handles non-origin remotes (upstream/main), multi-slash remote
names (company/fork/main), local-branch upstreams
(git branch -u <local>), and avoids misclassifying local branches
with slashes (feature/foo alongside a "feature" remote).
- refine's validateRefineContext only resolves @{upstream} when --since
is empty, so an unresolvable upstream doesn't block an otherwise-
valid --since invocation.
- Add refExists and listRemotes helpers used by the above.
Tests:
- TestGetUpstream: no upstream, remote tracking branch, named ref,
empty ref defaults to HEAD, local-branch upstream, missing-ref
surfaces UpstreamMissingError, and the rev-parse-exit-128-with-
configured-tracking case.
- TestIsOnBaseBranch: bare local, origin/-prefixed, non-origin remote
prefix, multi-slash remote name, the "feature/foo" local-branch
trap, and ambiguous refs.
- TestTryBranchReview: prefers branch upstream over default branch,
skips when upstream configured but unresolvable, blocks local main
tracking non-origin upstream.
- TestGetBranchFiles: prefers non-origin upstream, blocks on local
main tracking non-origin upstream.
- TestValidateRefineContext: prefers non-origin upstream, refuses
local main tracking non-origin upstream, --since bypasses upstream
resolution, UpstreamMissingError surfaces without --since.
0 commit comments