get
get(
config,refRange):Promise<string|null>
Defined in: packages/review/src/sources/gitDiffSource.ts:40
Gets a local diff via git --no-pager diff — review the working tree, a ref range, or a
branch against its merge base, without GitHub and without piping a diff through stdin.
Which diff, in order:
- An explicit
refRangealways wins and keeps its plain meaning,git diff <refRange>, whatevermergeBasesays. It is the more specific request: the user typed it for this run, whilemergeBaseis a standing default from config. - Otherwise, with
mergeBaseset, the working tree against the merge base of that ref andHEAD— what the branch’s pull request would show, plus uncommitted edits to tracked files. The base is resolved to a sha by resolveMergeBase (see there for why a sha, and why an unresolvable base fails instead of falling back), and the diff isgit diff <sha> --: the--stops git reading the sha as a path when a file of that name exists. Untracked files are not in it, as in anygit diff. - Otherwise the working tree against the index (plain
git diff).
mergeBase is validated here rather than in core’s config schema, which keeps every
content source’s block opaque (z.record(z.string(), z.unknown())) and leaves each source to
own its keys. It is validated on every call, even when an explicit refRange means it will not
be used: a malformed value is a config error that should surface on the first run, not on the
first run that happens to omit the id.
Parameters
Section titled “Parameters”config
Section titled “config”ProviderConfig | null
contentSourceConfig.git, if any. Recognised key: mergeBase (string); any
other key is ignored with a warning, so a typo such as mergebase is reported.
refRange
Section titled “refRange”string | undefined
optional revision selection passed to git diff, e.g. origin/main...HEAD
or HEAD~3.
Returns
Section titled “Returns”Promise<string | null>
the diff content; throws with a clear message outside a git repository, on a bad ref or merge base, or when the diff is empty (an empty review would otherwise run against no content).