Skip to content

resolveMergeBase

resolveMergeBase(base, origin?): Promise<string>

Defined in: packages/review/src/utils/git.ts:93

Resolve the merge base of base and HEAD to a commit sha, with git merge-base <base> HEAD.

This is the ONE place the merge base is computed, and it is shared on purpose: the git content source diffs against it, and a later reader that lists the branch’s commits (as requirements evidence) must compute its range from this same function. Two resolvers are how a reviewed diff and the evidence beside it would come to describe different branches.

Why a sha rather than git diff --merge-base <base>: that flag needs git 2.30+, and it would put a flag on git’s command line that came from the caller’s side of the seam. Resolving first works on any git, and what reaches git diff afterwards is a validated object name, never something option-shaped.

An unresolvable base throws; it never falls back to some other diff. A fallback (the plain working-tree diff, say) would silently review LESS than the user configured, which is worse than stopping. The messages name origin (by default the config key) so the user knows which setting to fix.

string

the configured ref, e.g. origin/main; rejected if it starts with -, so a value from config can never become a git flag.

string = MERGE_BASE_SETTING

what to call the value in error messages.

Promise<string>

the full merge-base commit sha.