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 short name when the ref exists
locally, and ("", *UpstreamMissingError) when the upstream is
configured but the referenced ref does not resolve. The verification
resolves the fully-qualified ref from branch.<name>.remote /
branch.<name>.merge — refs/heads/<merge> for local-branch tracking
(remote == "."), refs/remotes/<remote>/<merge> otherwise — so a
lookalike tag or local branch with the same short name cannot
shadow a missing remote-tracking ref. 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. A slash-
containing base is only treated 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
(longest match wins). 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, or even a local branch literally named
origin/foo).
- refine's validateRefineContext only resolves @{upstream} when
--since is empty, so an unresolvable upstream doesn't block an
otherwise-valid --since invocation.
- Add refExists, listRemotes, readGitConfig, and readUpstreamConfig
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, configured-but-never-fetched
tracking, and a colliding local ref at the same short name as a
missing remote-tracking ref.
- TestIsOnBaseBranch: bare local, origin/-prefixed, non-origin
remote prefix, multi-slash remote name, the "feature/foo"
local-branch trap, the pathological local "origin/foo", 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