MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / getDiffRef

Function getDiffRef

source code/utils/gitDiff.ts:492–504  ·  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

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

Callers 1

fetchSingleFileGitDiffFunction · 0.85

Calls 2

getDefaultBranchFunction · 0.85
execFileNoThrowWithCwdFunction · 0.85

Tested by

no test coverage detected