MCPcopy Index your code
hub / github.com/codeaashu/claude-code / getDiffRef

Function getDiffRef

src/utils/gitDiff.ts:490–502  ·  view source on GitHub ↗

* Determine the best ref to diff against for a PR-like diff. * Priority: * 1. CLAUDE_CODE_BASE_REF env var (set externally, e.g. by CCR managed containers) * 2. Merge base with the default branch (best guess) * 3. HEAD (fallback if merge-base fails)

(gitRoot: string)

Source from the content-addressed store, hash-verified

488 * 3. HEAD (fallback if merge-base fails)
489 */
490async function getDiffRef(gitRoot: string): Promise<string> {
491 const baseBranch =
492 process.env.CLAUDE_CODE_BASE_REF || (await getDefaultBranch())
493 const { stdout, code } = await execFileNoThrowWithCwd(
494 gitExe(),
495 ['--no-optional-locks', 'merge-base', 'HEAD', baseBranch],
496 { cwd: gitRoot, timeout: SINGLE_FILE_DIFF_TIMEOUT_MS },
497 )
498 if (code === 0 && stdout.trim()) {
499 return stdout.trim()
500 }
501 return 'HEAD'
502}
503
504async function generateSyntheticDiff(
505 gitPath: string,

Callers 1

fetchSingleFileGitDiffFunction · 0.85

Calls 2

getDefaultBranchFunction · 0.85
execFileNoThrowWithCwdFunction · 0.85

Tested by

no test coverage detected