Skip to content

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:

  1. An explicit refRange always wins and keeps its plain meaning, git diff <refRange>, whatever mergeBase says. It is the more specific request: the user typed it for this run, while mergeBase is a standing default from config.
  2. Otherwise, with mergeBase set, the working tree against the merge base of that ref and HEAD — 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 is git 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 any git diff.
  3. 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.

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.

string | undefined

optional revision selection passed to git diff, e.g. origin/main...HEAD or HEAD~3.

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).